我正在运行一个模型。它运行得非常完美,我不知道我做了什么,现在没有运行。小背景我制作了一个数据框,并为列中的所有NaN添加了值。然后创建我的预测器和目标,运行套索模型。当我运行lasso模型时,它给了我一个输入值error contains NaN、infinity或一个对dtype来说太大的值('float64')。 此外,我还通过运行final_data.isna().sum()仔细检查了我的列是否没有NaN值,并发现所有列都返回了0
def build_and_fit_lasso_model(X, y):
"""Creates and returns a LASSO model that is fitted to the values of the
given predictor and target X, and y.
"""
model = LassoLarsCV(cv=10, precompute = False)
model = model.fit(X_train.values, y_train.values)
return model # implement this function
然后当我运行时,这会给我错误
lasso_model = build_and_fit_lasso_model(X_train, y_train)
lasso_model
在我的数据框中有NAN,我的函数没有正确捕获它们。问题解决了
相关问题 更多 >
编程相关推荐