1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅͰúÇÐ(»ý´ÉÃâÆÇ»ç 2020) # LAB 14-2 µ¥ÀÌÅÍ 80%·Î ÇнÀÇÏ¿© ¿¹ÃøÇÑ °á°ú¿Í ½ÇÁ¦ µ¥ÀÌÅÍ ºñ±³, 382ÂÊ # import numpy as np from sklearn import linear_model # scikit-learn ¸ðµâÀ» °¡Á®¿Â´Ù from sklearn import datasets import matplotlib.pyplot as plt diabetes = datasets.load_diabetes() regr = linear_model.LinearRegression() # ÇнÀ µ¥ÀÌÅÍ¿Í Å×½ºÆ® µ¥ÀÌÅ͸¦ ºÐ¸®ÇÑ´Ù. from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(diabetes.data, diabetes.target, test_size=0.2) regr.fit(X_train, y_train) print(regr.coef_, regr.intercept_) y_pred = regr.predict(X_test) plt.scatter(y_pred, y_test) plt.show() | cs |