Advertisement
elena1234

logistic regression in Python

Sep 1st, 2023
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. from sklearn.preprocessing import StandardScaler
  2. scaler = StandardScaler()
  3. # transform data
  4. scaled_X_train = scaler.fit_transform(X_train)
  5. scaled_X_test = scaler.transform(X_test)
  6.  
  7.  
  8. from sklearn.linear_model import LogisticRegressionCV
  9. log_model = LogisticRegressionCV(cv=5, random_state=101).fit(scaled_X_train, y_train)
  10. log_model
  11.  
  12.  
  13. log_model.C_
  14.  
  15.  
  16. log_model.get_params()
  17.  
  18.  
  19. log_model.coef_
  20.  
  21.  
  22. coefs = pd.Series(index=X.columns,data=log_model.coef_[0])
  23. coefs = coefs.sort_values()
  24. plt.figure(figsize=(10,6))
  25. sns.barplot(x=coefs.index,y=coefs.values);
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement