I am new with sklearn
.
My objective is to estimate the score of a dataset using cross_val_score
with BayesianRidge
estimator. It should be implemented using an unsupervised learning
. The code below is taken from sklearn
except that the target variable
, y
, is excluded.
The data is taken from sklearn.datasets import fetch_california_housing
.
estimator = BayesianRidge()
score_full_data = pd.DataFrame(cross_val_score(br_estimator, X=X, y=None, scoring='neg_mean_squared_error', cv=5), columns=['Data'])
I got a TypeError: fit() missing 1 required positional argument: 'y'
.
The expected result is:
Data
0 -0.408433
1 -0.636009
2 -0.614910
3 -1.089616
4 -0.407541
How is the correct way to do it?
It's not working because of the fact that you are using a supervised
learning classifier and trying to use it as an unsupervised
classifier. You can't simply expect the underlying implementation of BayesianRidge
classifier to change just because you are not supplying the target
variable, ie y
. If you check the documentation here , you will see that y
is not an optional argument. Image from the link for reference:
Secondly, this is not an unsupervised learning problem in the first place. This dataset you mentioned is for regression. So it doesn't make sense to use unsupervised learning here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.