1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020) # 14.13 ¾Ë°í¸®ÁòÀÌ °¡Áö´Â ¿ÀÂ÷, 383ÂÊ # from sklearn import datasets from sklearn import linear_model import numpy as np from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt from sklearn.metrics import mean_squared_error # ´ç´¢º´ µ¥ÀÌÅÍ ¼¼Æ®¸¦ sklearnÀÇ µ¥ÀÌÅÍÁýÇÕÀ¸·ÎºÎÅÍ ÀоîµéÀδÙ. diabetes = datasets.load_diabetes() regr = linear_model.LinearRegression() 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) y_pred = regr.predict(X_test) plt.scatter(y_pred, y_test) # Æò±Õ Á¦°ö ¿ÀÂ÷¸¦ ±¸ÇÏ´Â ÇÔ¼ö print('Mean squared error:', mean_squared_error(y_test, y_pred)) #plt.scatter(y_pred, y_test, color='black') x = np.linspace(0, 330, 100) # ƯÁ¤ ±¸°£ÀÇ Á¡ plt.plot(x, x, linewidth=3, color='blue') plt.show() | cs |