near_zero=df['Budget'].clip(lower=0).replace(0,df['Budget'].max()).min()
这是我使用scikit库为Grid Search运行代码时出现的错误。
Input contains NaN, infinity or a value too large for dtype('float64')
我尝试使用dropna()并确保没有任何nan值
df= pd.read_csv('train.csv')
df.dropna(inplace=True)
X_train, X_test, y_train, y_test= train_test_split(df.drop(columns=['SalePrice']), df['SalePrice'], random_state=1)
mlp = MLPRegressor(max_iter=1000, hidden_layer_sizes=(667, 45, 45), random_state=1 )
parameter_space = {
'activation': ['tanh', 'relu', 'identity', 'logistic'],
'solver': ['sgd', 'adam', 'lbfgs'],
'alpha': [0.0001, 0.05],
'learning_rate': ['constant','adaptive'],
}
clf = GridSearchCV(mlp, parameter_space, n_jobs=-1, cv=3, scoring='neg_mean_squared_log_error')
clf.fit(X_train.values, y_train.values)
但是仍然返回相同的错误。为什么?