-1

I just tried to implement logistic regression on a very simple and small dataset at Jupyter notebook. But the output that I am getting at the end having applied the algorithm is unwanted and shocking. I am getting the output as LogisticRegression() only nothing but only this.


import numpy as np import pandas as pd

df = pd.read_csv('placement.csv')

df.head()

df.info()

df = df.iloc[:,1:]

df.head()


import matplotlib.pyplot as plt

plt.scatter(df['cgpa'],df['iq'],c=df['placement'])

X = df.iloc[:,0:2]
y = df.iloc[:,-1]
     

X

from sklearn.model_selection import train_test_split

X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.1)
     

X_train

y_train


X_test

y_test


from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()

X_train = scaler.fit_transform(X_train)

X_train

X_test = scaler.transform(X_test)

X_test

from sklearn.linear_model import LogisticRegression

clf = LogisticRegression()

clf.fit(X_train,y_train)

LogisticRegression() ## at the end I get this.

Please bear with me for the way I have uploaded the code. How can I fix this output of logisticregression(), need help.

  • You need to call `clf.predict(X_test)`. – Alexander L. Hayes Jan 02 '23 at 16:36
  • 1
    The `fit()` method returns `self`, so the Jupyter notebook is automatically invoking the `repr(clf)` as the cell output. – Alexander L. Hayes Jan 02 '23 at 16:38
  • So I need to add clf.predict(X_test). But after which line, clf = LogisticRegression() or clf.fit(X_train,y_train) – Partha Pratim Sarma Jan 02 '23 at 16:43
  • (1) Initialize a model, (2) Fit a model, (3) Predict with a model. Prediction happens at the end. – Alexander L. Hayes Jan 02 '23 at 16:46
  • I am new to ml and I am doing this code by watching someone. I am expecting something like this after this line, clf.fit(X_train,y_train) LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True, intercept_scaling=1, l1_ratio=None, max_iter=100, multi_class='auto', n_jobs=None, penalty='l2', random_state=None, solver='lbfgs', tol=0.0001, verbose=0, warm_start=False) – Partha Pratim Sarma Jan 02 '23 at 16:56
  • 1
    You're probably watching an old tutorial (before 2020?). The scikit-learn model `__repr__` implementations were updated so they would not display default parameters when printing some time back. – Alexander L. Hayes Jan 02 '23 at 17:10
  • 1
    See also https://stackoverflow.com/q/62825515/10495893, https://datascience.stackexchange.com/q/82217/55122 – Ben Reiniger Jan 03 '23 at 04:45
  • I have watched the video of march 2021. By the way thanks for the information. – Partha Pratim Sarma Jan 03 '23 at 07:06
  • Can you help me the with another problelm, https://stackoverflow.com/questions/74946960/anaconda-prompt-is-having-an-issue-with-ssl-certificates , I have tried to do many things which worked for a lot people such as working with DLL files etc. But nothing is working at all for me. If try to do conda config --set ssl_verify false ,it is also not a suitable solution as I am not able to install any packages at all and it is related to security too. This problem has denied me to do anything at all to learn to practice. Please share a solution if possible. – Partha Pratim Sarma Jan 03 '23 at 07:14

1 Answers1

0

From my error I get to know that the scikit-learn model repr implementations were updated so they would not display default parameters when printing some time back.