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 29 30 | # # µû¶óÇÏ¸ç ¹è¿ì´Â ÆÄÀ̽ã°ú µ¥ÀÌÅÍ°úÇÐ(»ý´ÉÃâÆÇ»ç 2020) # 14.7 ¼±Çü ȸ±Í ÇнÀ°á°ú¸¦ È®ÀÎÇÏ°í ¿¹ÃøÇϱâ, 374ÂÊ # #14-6ÀÇ ÄÚµå import numpy as np from sklearn import linear_model # scikit-learn ¸ðµâÀ» °¡Á®¿Â´Ù regr = linear_model.LinearRegression() X = [[164], [179], [162], [170]] # ´ÙÁßȸ±Í¿¡µµ »ç¿ëÇϵµ·Ï ÇÔ y = [53, 63, 55, 59] # y = f(X)ÀÇ °á°ú regr.fit(X, y) ######################################## coef = regr.coef_ # Á÷¼±ÀÇ ±â¿ï±â intercept = regr.intercept_ # Á÷¼±ÀÇ ÀýÆí score = regr.score(X, y) # ÇнÀµÈ Á÷¼±ÀÌ µ¥ÀÌÅ͸¦ ¾ó¸¶³ª Àß µû¸£³ª print("y =", coef, "* X + ", intercept) print("The score of this line for the data: ", score) #################################### input_data = [ [180], [185] ] result = regr.predict(input_data) print(result) | cs |