import pickle
import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn import metrics
with open(r"D:\models\gender_model_1.pkl","rb") as f:
model_pickle=f.read()
model_new = pickle.loads(model_pickle)
data = pd.read_csv(r"D:\data\gender_testdata.csv")
X=data.drop(["gender"],axis=1).values
Y=np.array(data["gender"])
y_pred = model_new.predict(X)
y_prob = model_new.predict_proba(X)
y_yuzhi = []
y_prob[:,1]
for i in y_prob[:,1]:
if i>=0.6:
y_yuzhi.append(1)
else:
y_yuzhi.append(0)
print(metrics.classification_report(Y,y_pred))
print(metrics.classification_report(Y,y_yuzhi))
机器学习(自定义预测阈值)
最新推荐文章于 2024-11-02 13:03:38 发布