from sklearn
import datasets
iris
=datasets
.load_iris
()
list(iris
.keys
())
import numpy
as np
X
=iris
['data'][:,3:]
y
=(iris
['target']==2).astype
(np
.int)
from sklearn
.linear_model
import LogisticRegression
import matplotlib
.pyplot
as plt
log_reg
= LogisticRegression
()
log_reg
.fit
(X
,y
)
X_new
=np
.linspace
(0,3,1000).reshape
(-1,1)
y_proba
=log_reg
.predict_proba
(X_new
)
plt
.plot
(X_new
,y_proba
[:,1],'g-',label
='virginica ')
plt
.plot
(X_new
,y_proba
[:,0],'b--',label
='not virginica ')
plt
.legend
()
转载请注明原文地址:https://ipadbbs.8miu.com/read-55543.html