1

I'm trying to run a logistic regression model from sklearn.

But when I run model.fit(), it asks 3 parameters (self, X, and y). So what is this "self" parameter actually, and how can I run the model properly?

Here's my code:

from sklearn.linear_model import LogisticRegression
logR = LogisticRegression.fit(X = X_train, y= y_train)

and here's the error message:

TypeError                                 Traceback (most recent call last)
<ipython-input-112-630096e6bf16> in <module>
      1 from sklearn.linear_model import LogisticRegression
----> 2 logR = LogisticRegression.fit(X = X_train, y= y_train)

TypeError: fit() missing 1 required positional argument: 'self'
NelsonGon
  • 12,469
  • 5
  • 25
  • 52

1 Answers1

3

Self is not a parameter to input, it is an indicator for the OOP programming style. In other words, ignore it.

logr = LogisticRegression()

logr.fit(X_train,y_train)

This should do the job.

Click here to read more about Self

ombk
  • 2,008
  • 1
  • 3
  • 15