Python/Python기초

from sklearn import datasetsimport pandas as pdimport seaborn as snsimport matplotlib.pyplot as plt iris = datasets.load_iris()X = iris['data'] # iris.datay = iris['target'] # iris.targetfeatures = iris['feature_names'] # iris.feature_namesprint(features)['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'] iris_df = pd.DataFrame(X,columns=['sepal_length', 'sepal_wid..
import seaborn as snsimport matplotlib.pyplot as pltfrom sklearn.datasets import load_bostonimport pandas as pd boston = load_boston()X = boston['data'] # boston.datay = boston['target'] # boston.targetfeatures = boston['feature_names'] # boston.feature_names # DataFrame으로 변환boston_df = pd.DataFrame(X, columns = features, index= None) boston_df['Price'] = yprint(boston_df.head())print(boston_df...
회귀분석 응용RM ~ LSTAT 두 변수를 이용한 다중회귀분석 # Price ~ RM + LSTAT + RM**2 + RM * LSTAT + LSTAT**2# Price = b0 + b1 * rm + b2 * lstat + b3 * rm**2 + b4 * rm * lstat + b5 * lstat **2# 학습 세트에 다항식항(컬럼)을 추가X_train_rm_lstat_poly = poly.fit_transform(X_train_rm_lstat)# 테스트 세트에 다항식항(컬럼)을 추가X_test_rm_lstat_poly = poly.fit_transform(X_test_rm_lstat)print(X_test_rm_lstat_poly[:2])lin_reg.fit(X_train_rm_lstat_poly, y..
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와..
Codezoy
'Python/Python기초' 카테고리의 글 목록 (2 Page)