Home > OS >  Python Logistic Regression Positional Argument
Python Logistic Regression Positional Argument

Time:08-05

The following is my code:

x = hrdf[['JobSatisfaction', 'HourlyRate', 'WorkLifeBalance']]
y = hrdf['Attrition']

X_train, X_test, y_train, y_test = train_test_split(x, y, test_size = 0.3, random_state = 0)
log_regression = LogisticRegression

log_regression.fit(X_train, y_train)

y_pred = log_regression.predict(X_test)

and the error I receive is:

TypeError: fit() missing 1 required positional argument: 'y'

Not sure where I went wrong with fitting the model.

CodePudding user response:

Your issue is log_regression = LogisticRegression, and it is thinking its an object type, not an instance.

You just need to make it log_regression = LogisticRegression()

  • Related