当前位置:   article > 正文

使用Python进行logistic regression_python中调用logisticregression函数需要加载哪个包

python中调用logisticregression函数需要加载哪个包
  1. # Step 1: Import packages, functions, and classes
  2. import numpy as np
  3. import seaborn as sns
  4. from sklearn.linear_model import LogisticRegression
  5. from sklearn.metrics import classification_report, confusion_matrix
  6. sns.set_theme()# 设置风格
  7. %config InlineBackend.figure_format = 'retina' # 让图片更清晰
  8. # Step 2: Get data
  9. x = np.arange(10).reshape(-1, 1)
  10. y = np.array([0, 1, 0, 0, 1, 1, 1, 1, 1, 1])
  11. # Step 3: Create a model and train it
  12. model = LogisticRegression()
  13. model.fit(x, y)
  14. # Step 4: Evaluate the model
  15. p_pred = model.predict_proba(x)
  16. y_pred = model.predict(x)
  17. score_ = model.score(x, y)
  18. conf_m = confusion_matrix(y, y_pred)
  19. report = classification_report(y, y_pred)
  20. print('report:', report, sep='\n')

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/544750
推荐阅读
相关标签
  

闽ICP备14008679号