Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -23,6 +23,7 @@ def homework01_solution1(K, X1, X2):
|
|
23 |
neigh = KNeighborsRegressor(n_neighbors=K)
|
24 |
neigh.fit(X, y)
|
25 |
predicted_label = neigh.predict(np.array([[X1, X2]]))[0]
|
|
|
26 |
|
27 |
#(Q) calculate squared error
|
28 |
pred = neigh.predict(X)
|
@@ -31,7 +32,7 @@ def homework01_solution1(K, X1, X2):
|
|
31 |
#(Q2.3) evaluate mean squared error
|
32 |
import sklearn
|
33 |
y_pred = neigh.predict(X)
|
34 |
-
mse = sklearn.metrics.mean_squared_error(y,y_pred)
|
35 |
|
36 |
|
37 |
train_data['Predicted Label ('+str(K)+'-NN)'] = pred
|
|
|
23 |
neigh = KNeighborsRegressor(n_neighbors=K)
|
24 |
neigh.fit(X, y)
|
25 |
predicted_label = neigh.predict(np.array([[X1, X2]]))[0]
|
26 |
+
predicted_label = np.round(predicted_label, 3)
|
27 |
|
28 |
#(Q) calculate squared error
|
29 |
pred = neigh.predict(X)
|
|
|
32 |
#(Q2.3) evaluate mean squared error
|
33 |
import sklearn
|
34 |
y_pred = neigh.predict(X)
|
35 |
+
mse = np.round(sklearn.metrics.mean_squared_error(y,y_pred),3)
|
36 |
|
37 |
|
38 |
train_data['Predicted Label ('+str(K)+'-NN)'] = pred
|