bartmiller commited on
Commit
547800a
·
verified ·
1 Parent(s): be2f547

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -7,32 +7,32 @@ from sklearn.preprocessing import StandardScaler
7
  from sklearn.linear_model import LinearRegression
8
  from sklearn.metrics import mean_squared_error, r2_score
9
 
10
- # # Load the California Housing dataset
11
- # data = fetch_california_housing(as_frame=True)
12
- # X = data.data
13
- # y = data.target
14
 
15
- # # Split the dataset into training and test sets
16
- # X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
17
 
18
- # # Standardize features
19
- # scaler = StandardScaler()
20
- # X_train = scaler.fit_transform(X_train)
21
- # X_test = scaler.transform(X_test)
22
 
23
- # # Train the model
24
- # model = LinearRegression()
25
- # model.fit(X_train, y_train)
26
 
27
- # # Make predictions on the test set
28
- # y_pred = model.predict(X_test)
29
 
30
- # # Evaluate the model
31
- # mse = mean_squared_error(y_test, y_pred)
32
- # r2 = r2_score(y_test, y_pred)
33
 
34
- # print(f"Mean Squared Error: {mse:.2f}")
35
- # print(f"R-squared Score: {r2:.2f}")
36
 
37
  sentiment_pipeline = pipeline("sentiment-analysis")
38
 
 
7
  from sklearn.linear_model import LinearRegression
8
  from sklearn.metrics import mean_squared_error, r2_score
9
 
10
+ # Load the California Housing dataset
11
+ data = fetch_california_housing(as_frame=True)
12
+ X = data.data
13
+ y = data.target
14
 
15
+ # Split the dataset into training and test sets
16
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
17
 
18
+ # Standardize features
19
+ scaler = StandardScaler()
20
+ X_train = scaler.fit_transform(X_train)
21
+ X_test = scaler.transform(X_test)
22
 
23
+ # Train the model
24
+ model = LinearRegression()
25
+ model.fit(X_train, y_train)
26
 
27
+ # Make predictions on the test set
28
+ y_pred = model.predict(X_test)
29
 
30
+ # Evaluate the model
31
+ mse = mean_squared_error(y_test, y_pred)
32
+ r2 = r2_score(y_test, y_pred)
33
 
34
+ print(f"Mean Squared Error: {mse:.2f}")
35
+ print(f"R-squared Score: {r2:.2f}")
36
 
37
  sentiment_pipeline = pipeline("sentiment-analysis")
38