본문 바로가기
728x90

기계학습(ML)13

n221 Decision Trees, gini, entropy 사이킷런 파이프라인(pipelines) 을 이해하고 활용 할 수 있습니다. 사이킷런 결정트리(decision tree) 를 사용할 수 있습니다. 결정트리의 특성 중요도(feature importances) 를 활용할 수 있습니다. 결정트리 모델의 장점을 이해하고 선형회귀모델과 비교할 수 있습니다. 모든 binary binary 변수는 다음과 같은 규칙을 따릅니다. 0 : No / 1 : Yes *지도학습 ==> train set을 학습 알고리즘에 넣은 다음 가설함수 도출 train set 알고리즘 price -> 가설함수 -> 추정치( predict ) 1. Train data ==> train / val set으로 나눔 # profiling ! pip install pandas-profiling==2... 2021. 6. 19.
n214 Logistic Regression / validation Test set(테스트 데이터)은 validation set으로 사용할 모델이 결정 된 후, 마지막으로 딱 한번 해당 모델의 예상되는 성능을 측정하기 위해 사용된다. 이미 validation set은 여러 모델에 반복적으로 사용되었고 그중 운 좋게 성능이 보다 더 뛰어난 것으로 측정되어 모델이 선택되었을 가능성이 있다. 때문에 이러한 오차를 줄이기 위해 한 번도 사용해본 적 없는 test set을 사용하여 최종 모델의 성능을 측정하게 된다. 최종테스트 결과가 마음에 들지 않는다고 모델을 또 수정하여 테스트 세트를 더 잘 예측하는 모델을 만든다면 그 모델은 테스트세트에 과적합하여 일반화 성능이 떨어지게 될 수 있습니다 * Train = 모델을 Fit 하는데 사용합니다 * Test = 성능이 좋은지 최종 확.. 2021. 6. 14.
n213 Ridge Regression, onehotencoding import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression, LogisticRegression, Ridge, RidgeCV, Lasso, LassoCV, ElasticNet,ElasticNetCV from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split from sklearn.metrics import r2_score, mean_squared_error ##범주 비율 df['City'].value_counts(normalize=True) ## aggregation을 사용해 City .. 2021. 6. 12.
n212 Multiple Linear Regression / 과적합 과소적합 import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression, LogisticRegression, Ridge, RidgeCV from sklearn.preprocessing import StandardScaler, PolynomialFeatures from sklearn.model_selection import train_test_split # X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=1) from sklearn.metrics import r2_score, mean_squared_error * Train data / Tes.. 2021. 6. 12.
n211 Simple Regression import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression, LogisticRegression, Ridge, RidgeCV, from sklearn.preprocessing import StandardScaler from sklearn.model_selection import train_test_split from sklearn.metrics import r2_score, mean_squared_error *sns.pairplot(df[cols], height=2); ==> 전체 변수와의 관계를 보여줌 *머신러닝이란? Data, Answer ==> ML model ==> rule = 지도학습( 데이터와 답.. 2021. 6. 12.
728x90