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.12 ´ç´¢º´ ¿¹Á¦¸¦ ÇнÀ µ¥ÀÌÅÍ¿Í Å×½ºÆ® µ¥ÀÌÅÍ·Î ±¸ºÐÇÏÀÚ, 381ÂÊ # import matplotlib.pyplot as plt import numpy as np from sklearn.linear_model import LinearRegression from sklearn import datasets from sklearn.model_selection import train_test_split # ´ç´¢º´ µ¥ÀÌÅÍ ¼¼Æ®¸¦ sklearnÀÇ µ¥ÀÌÅÍÁýÇÕÀ¸·ÎºÎÅÍ ÀоîµéÀδÙ. diabetes = datasets.load_diabetes() X_train, X_test, y_train, y_test = train_test_split(diabetes.data, diabetes.target, test_size = 0.2) regr = LinearRegression() regr.fit(X_train, y_train) y_pred = regr.predict(X_test) # Å×½ºÆ® µ¥ÀÌÅÍ·Î ¿¹ÃøÇغ¸ÀÚ. mse_set = (y_pred - y_test) ** 2 sum_mse = 0.0 for value in mse_set: sum_mse += value mse = sum_mse / len(mse_set) print('Æò±ÕÁ¦°ö ¿ÀÂ÷(MSE):', mse) | cs |