Error with Python: TypeError: fit() missing 1 required positional argument: 'y'
Error with Python: TypeError: fit() missing 1 required positional argument: 'y'
每次我 运行 下面的代码时,我都会收到一条错误消息,提示 fit 缺少 1 个必需的位置参数 (y),但我的“y”值是在我的代码中指定的。
X_var = myData['PredictorName']
y = myData['TaskOutcome']
LogisticRegression()
LogisticRegression.fit(X_var, y)
我尝试了多种不同的方法将数据拉出 df,但 none 似乎有效。
这是我对 y.head() 的输出(它应该是一系列 1 和 0)
0 0
1 1
2 0
3 1
4 0
Name: Task, dtype: int64
您需要将对构造函数的调用分配给一个变量,然后对该变量调用 fit 函数。
X_var = myData['PredictorName']
y = myData['TaskOutcome']
logistic_regression = LogisticRegression()
logistic_regression.fit(X_var, y)
每次我 运行 下面的代码时,我都会收到一条错误消息,提示 fit 缺少 1 个必需的位置参数 (y),但我的“y”值是在我的代码中指定的。
X_var = myData['PredictorName']
y = myData['TaskOutcome']
LogisticRegression()
LogisticRegression.fit(X_var, y)
我尝试了多种不同的方法将数据拉出 df,但 none 似乎有效。
这是我对 y.head() 的输出(它应该是一系列 1 和 0)
0 0
1 1
2 0
3 1
4 0
Name: Task, dtype: int64
您需要将对构造函数的调用分配给一个变量,然后对该变量调用 fit 函数。
X_var = myData['PredictorName']
y = myData['TaskOutcome']
logistic_regression = LogisticRegression()
logistic_regression.fit(X_var, y)