Python Logistic Regression Positional Argument

Question:

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.

Asked By: Brandi Austin

||

Answers:

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()

Answered By: MrFrknFantastic
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.