from sklearn import datasets
from sklearn import linear_model
yuan = datasets.load_iris()
print(yuan)
import pandas as pd
te_zheng = pd.DataFrame(yuan.data)
species = pd.DataFrame(yuan.target)
df = pd.concat([te_zheng,species] , axis =1)
df.columns=["花萼长度","花萼宽度","花瓣长度","花瓣宽度","种类"]
"""
"花萼长度"," 花萼宽度","花瓣长度","花瓣宽度"
花萼宽度", "花瓣长度","花瓣宽度"
"花瓣长度", "花瓣宽度"
"""
print(df.head())
import matplotlib.pyplot as plt
plt.plot(df["花瓣长度"][0:49], df["花萼长度"][0:49], "bo")
plt.plot(df["花瓣长度"][50:99], df["花萼长度"][50:99], "go")
plt.plot(df["花瓣长度"][100:149], df["花萼长度"][100:149], "ro")
plt.show()
mo_xing = linear_model.LogisticRegression()
mo_xing.fit(te_zheng, species)
yu_ce = mo_xing.predict([[40, 40, 40, 40]])
print(yu_ce)
score = mo_xing.score(te_zheng, species)
print(score)