赞
踩
- # Step 1: Import packages, functions, and classes
- import numpy as np
- import seaborn as sns
- from sklearn.linear_model import LogisticRegression
- from sklearn.metrics import classification_report, confusion_matrix
-
- sns.set_theme()# 设置风格
- %config InlineBackend.figure_format = 'retina' # 让图片更清晰
-
- # Step 2: Get data
- x = np.arange(10).reshape(-1, 1)
- y = np.array([0, 1, 0, 0, 1, 1, 1, 1, 1, 1])
-
- # Step 3: Create a model and train it
- model = LogisticRegression()
- model.fit(x, y)
-
- # Step 4: Evaluate the model
- p_pred = model.predict_proba(x)
- y_pred = model.predict(x)
- score_ = model.score(x, y)
- conf_m = confusion_matrix(y, y_pred)
- report = classification_report(y, y_pred)
-
- print('report:', report, sep='\n')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。