1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020) # 14.10 üÁú·®Áö¼ö¿Í ´ç´¢¼öÄ¡´Â ¾î¶² »ó°ü°ü°è°¡ ÀÖÀ»±î, 379ÂÊ # from sklearn import datasets from sklearn import linear_model import numpy as np 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[:, np.newaxis, 2], diabetes.target, test_size = 0.2) regr = linear_model.LinearRegression() regr.fit(X_train, y_train) score = regr.score(X_train, y_train) print(score) score = regr.score(X_test, y_test) print(score) | cs |