jiehou commited on
Commit
1ff0af5
1 Parent(s): 156973e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
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