Python

import sklearn.datasetsimport numpy as npimport matplotlib.pyplot as pltfrom sklearn.linear_model import LinearRegressionfrom sklearn.metrics import mean_squared_error, r2_scorefrom sklearn.model_selection import train_test_splitfrom sklearn.preprocessing import PolynomialFeatures # 보스턴 집값 데이터 세트 로딩skl_data = sklearn.datasets.load_boston(return_X_y=False)print(type(skl_data)) # Bunch: 파이썬의 Dict와..
y = b + a * x: linear regressiony = b + a1 * x + a2 * x^2 -> 선형 회귀로 b, a1, a2를 결정할 수 있다. y = b + a1 * x1 + a2 * x2: 선형 회귀y = b + a1 * x1 + a2 * x2 + a3 * x1^2 + a4 * x1 * x2 + a5 * x2^2 import numpy as npimport matplotlib.pyplot as plt # Training Set - data : 범위 -3
import numpy as npimport matplotlib.pyplot as pltfrom sklearn.linear_model import LinearRegression 임의의 X, y 값 설정np.random.seed(1216)X = 2 * np.random.rand(100, 1)print('X shape:', X.shape) # 0.0 ~ 2.0 숫자들로 이루어진 100x1 행렬(2차원 ndarray) y = 4 + 3 * X + np.random.randn(100, 1)print('y shape', y.shape) X shape: (100, 1)y shape (100, 1) plt.scatter(X, y)plt.show() X_b = 행렬 [1 , X]로 구성 X_b = np.c_[np.on..
사이킷런의 linear_regression 사용하기 위한 패키지 importimport numpy as npimport matplotlib.pyplot as pltfrom sklearn import linear_modelfrom sklearn.datasets import load_diabetes 비만 데이터 LoadX, y = load_diabetes(return_X_y=True)print(X[:5])print(X.shape, y.shape) [[ 0.03807591 0.05068012 0.06169621 0.02187235 -0.0442235 -0.03482076 -0.04340085 -0.00259226 0.01990842 -0.01764613][-0.00188202 -0.04464164 -0.051..
Codezoy
'Python' 카테고리의 글 목록 (7 Page)