본문 바로가기

Machine Learning

(47)
Classification - RandomForestClassifier https://steadiness-193.tistory.com/257 Machine Learning - valid와 test를 train으로 전처리 https://steadiness-193.tistory.com/256 Machine Learning - train_test_split https://steadiness-193.tistory.com/253 Machine Learning - 랜덤으로 train과 test로 나누기 데이터 불러오기 seaborn의 iris 데.. steadiness-193.tistory.com 위 포스팅에서 만든 데이터셋을 이용한다. [RandomForestClassifier] 여러 개의 모델을 합치는 앙상블의 대표적 모델 서로 다른 변수 셋으로 여러 트리를 생성 [파라미터] n_..
Classification - DecisionTreeClassifier [DecisionTreeClassifier] 각 영역의 복잡도가 낮은 기준점으로 잘라(분기) 트리 형태의 구조로 분류하는 모델 Greedy한 알고리즘 : 분기를 한번 하면 최적의 트리 형태가 발견되더라도 되돌려서 재분기하지 않음 최적의 트리 생성을 보장하지 않기에 속도가 빠름 [파라미터] - max_depth : 생성할 DecisionTree의 깊이 (int) - max_features : DT가 사용하는 feature의 수 (float) - min_samples_split : 구간의 데이터 수가 N개 미만이면 더이상 분기하지 않음 (int) 과적합 방지 - max_leaf_nodes : 리프 노드에서 최대로 가지고 있을 수 있는 데이터의 수 (int) - random_state : 난수 (int) 복잡..
Classification - SVM 서포트 벡터 머신 https://steadiness-193.tistory.com/257 Machine Learning - valid와 test를 train으로 전처리 https://steadiness-193.tistory.com/256 Machine Learning - train_test_split https://steadiness-193.tistory.com/253 Machine Learning - 랜덤으로 train과 test로 나누기 데이터 불러오기 seaborn의 iris 데.. steadiness-193.tistory.com 위 포스팅에서 만든 데이터셋을 이용한다. 분류이기 때문에 SVM에서의 SVC를 불러왔다. 아무 파라미터 없이 기본으로 SVC로 예측한 뒤 정확도를 평가했다. [Support Vector Ma..
Classification - 정확도 평가 : accuracy_score 분류에서는 일반적으로 accuracy (정확도)를 평가한다. from sklearn.metrics import accuracy_score accuracy_score에 정답배열과 예측값의 배열을 넣으면 정확도가 평가된다. 예시. accuracy_score(y_train, y_valid) * 100 93.41
Machine Learning - valid와 test를 train으로 전처리 https://steadiness-193.tistory.com/256 Machine Learning - train_test_split https://steadiness-193.tistory.com/253 Machine Learning - 랜덤으로 train과 test로 나누기 데이터 불러오기 seaborn의 iris 데이터셋을 불러온다. 150개의 행 중 100개를 train, 50개를 test로 나눠보자 단,.. steadiness-193.tistory.com 위에서 만든 데이터 셋을 이용한다. 숫자형 데이터는 train 데이터셋의 컬럼별 평균값으로, 범주형 데이터는 train 데이터셋의 컬럼별 최빈값으로 채워준다. train과 valid, test 데이터셋의 결측값의 개수는 총 0개로 바뀌었다. [t..
Machine Learning - train_test_split https://steadiness-193.tistory.com/253 Machine Learning - 랜덤으로 train과 test로 나누기 데이터 불러오기 seaborn의 iris 데이터셋을 불러온다. 150개의 행 중 100개를 train, 50개를 test로 나눠보자 단, 인덱스순이 아닌 랜덤으로 추출해서 진행한다. id 컬럼 추가 랜덤 추출 https://steadiness-19.. steadiness-193.tistory.com 위 포스팅에서는 sample 메서드를 이용해서 나누어봤으나 좀 더 정밀하게 나눌 수 있는 sklearn 패키지의 train_test_split 을 이용해보자. 데이터 출처 www.kaggle.com/c/titanic Titanic: Machine Learning fro..
Classification - DecisionTreeClassifier 맛보기 https://steadiness-193.tistory.com/253 Machine Learning - 랜덤으로 train과 test로 나누기 데이터 불러오기 seaborn의 iris 데이터셋을 불러온다. 150개의 행 중 100개를 train, 50개를 test로 나눠보자 단, 인덱스순이 아닌 랜덤으로 추출해서 진행한다. id 컬럼 추가 랜덤 추출 https://steadiness-19.. steadiness-193.tistory.com 위에서 만들어낸 train과 test를 이용한다. DecisionTreeClassifier [DecisionTreeClassifier] min_samples_split : 의사결정나무에서 최종 노드의 최소 샘플 수 제한 * 샘플 수가 10개 미만이라면 더 나누지 않는다..
Machine Learning - 랜덤으로 train과 test로 나누기 데이터 불러오기 seaborn의 iris 데이터셋을 불러온다. 150개의 행 중 100개를 train, 50개를 test로 나눠보자 단, 인덱스순이 아닌 랜덤으로 추출해서 진행한다. id 컬럼 추가 랜덤 추출 https://steadiness-193.tistory.com/252 판다스 - 데이터프레임 랜덤 추출 : DataFrame.sample 데이터 불러오기 편하게 10개 행만 가져온다. [DataFrame.sample(frac, n, replace, random_state)] frac 전체 행에서 몇 %만 추출할 것인가 0~1까지의 값을 넣을 수 있다. n 몇개의 행을 추출할 것인가 * frac과.. steadiness-193.tistory.com train 100개 행을 랜덤으로 추출해서 가져왔다...