pypipython-3.x95% confidence\u2191 105

SKLearn warning "valid feature names" in version 1.0

Full error message
I'm getting the following warning after upgrading to version 1.0 of scikit-learn:

UserWarning: X does not have valid feature names, but IsolationForest was
fitted with feature name

I cannot find in the docs on what is a "valid feature name". How do I deal with this warning?

I got the same warning message with another sklearn model. I realized that it was showing up because I fitted the model with a data in a dataframe, and then used only the values to predict. From the moment I fixed that, the warning disappeared. Here is an example: model_reg.fit(scaled_x_train, y_train[vp].values) data_pred = model_reg.predict(scaled_x_test.values) This first code had the warning, because scaled_x_train is a DataFrame with feature names, while scaled_x_test.values is only values, without feature names. Then, I changed to this: model_reg.fit(scaled_x_train.values, y_train[vp].values) data_pred = model_reg.predict(scaled_x_test.values) And now there are no more warnings on my code.

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/ea78ee12f625ba3edd4c83cf38e057bb873c0f115e68a2d9627bdc2ea1f8c8d0
hash \u00b7 ea78ee12f625ba3edd4c83cf38e057bb873c0f115e68a2d9627bdc2ea1f8c8d0
SKLearn warning "valid feature names" in version 1… — DepScope fix | DepScope