标签:gre int ESS ret python logistic mat near 行数据
from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression #X的shape是(150,4),y是个一维数组,长度为150,可能有3种标签 X, y = load_iris(return_X_y=True) #训练模型 clf = LogisticRegression(random_state=0).fit(X, y) #处理前两行,所有列。predict,返回的是这两行数据的预测结果,shape为(2,) labels = clf.predict(X[:2, :]) print(labels.shape) #Probability estimates,返回的是各个标签的可能性,得到的shape为(2,3) probs = clf.predict_proba(X[:2, :]) print(probs.shape) #计算预测的成功率(对每个X计算出y,再和实际的y比较) print(clf.score(X, y))
标签:gre int ESS ret python logistic mat near 行数据
原文地址:https://www.cnblogs.com/zz962/p/14453546.html