반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

sklearn.linearRegression 본문

[AI]/python.sklearn

sklearn.linearRegression

givemebro 2020. 3. 27. 00:29
반응형
from sklearn.neighbors import KNeighborsClassifier
X=iris[:,:4]
y=iris[:,4]

knn=KNeighborsClassifier()
knn.fit(X,y)
knn.score(X,y)
knn.predict(X)
from sklearn.linear_model import LinearRegression

linear=LinearRegression()
linear.fit(iris[:,[2]],iris[:,3])
기울기 = linear.coef_[0]
절편 = linear.intercept_
기울기, 절편
plt.scatter(iris[:,2],iris[:,3])
plt.xlabel('PetalLength')
plt.ylabel('PetalWidth')

plt.plot([0,7],[절편,7*기울기+절편],'r:')

반응형
Comments