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
  • 13,015
  • 7
  • 27
  • 57
Sigmalalalala
  • 117
  • 1
  • 9

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,036
  • 1
  • 4
  • 16