Screen Link:
My Code:
from sklearn.metrics import mean_squared_error
train_columns = ['accommodates', 'bathrooms']
knn = KNeighborsRegressor(n_neighbors=5, algorithm='brute', metric='euclidean')
knn.fit(train_df[train_columns], train_df['price'])
predictions = knn.predict(test_df[train_columns])
two_features_mse = mean_squared_error(test_df['price'], predictions)
two_features_rmse = mean_squared_error(test_df['price'], predictions, squared=False)
print(two_features_mse, two_features_rmse)
What I expected to happen:
Pass
What actually happened:
TypeErrorTraceback (most recent call last)
<ipython-input-1-3d17d90e5339> in <module>()
6 predictions = knn.predict(test_df[train_columns])
7
----> 8 two_features_mse = mean_squared_error(test_df['price'], predictions, squared=True)
9 two_features_rmse = mean_squared_error(test_df['price'], predictions, squared=False)
10
TypeError: mean_squared_error() got an unexpected keyword argument 'squared'
Hi
I’m completing the practice ‘8. Calculating MSE using Scikit-Learn’ under ‘Multivariate K-Nearest Neighbors’. I followed the documentation to get RMSE by using the ‘squared’ argument but didn’t get the expected output.
Documentation here: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_error.html#sklearn.metrics.mean_squared_error
Please could anyone help? Thanks in advance!