기본 콘텐츠로 건너뛰기

라벨이 precision_recall_curve인 게시물 표시

[matplotlib]quiver()함수

[ML] 이진 분류 추정기의 평가

이진분류기의 평가 이진 분류를 위해 로지스틱 모델을 사용합니다. 모델 생성을 위해 사용한 데이터셋은 pima-indians-diabetes.csv로서 Kaggle 에서 가져올 수 있습니다. 이 파일은 .csv 형식이므로 pandas.read_csv("경로")를 통해 호출할 수 있습니다. import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from sklearn.model_selection import train_test_split from sklearn.metrics import accuracy_score, precision_score, recall_score, roc_auc_score from sklearn.metrics import f1_score, confusion_matrix, precision_recall_curve, roc_curve from sklearn.preprocessing import StandardScaler, Binarizer from sklearn.linear_model import LogisticRegression data = pd.read_csv('pima-indians-diabetes.csv') data.head(3) preg plas pres skin test mass pedi age class 0 6 148 72 35 0 33.6 0.627 50 1 1 1 85 66 29 0 26.6...

[ML]이진 분류(Binary Classification): SGDClassifier

이진분류(Binary Classification): SGDClassifier 내용 SGDClassifier 모형평가:교차검증(Cross-Validation) import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns sns.set_style("darkgrid") SGDClassifier 다음은 make_classification() 함수를 사용하여 2개의 특징과 2개의 클래스로 구성된 라벨인 데이터를 생성한것입니다. from sklearn.datasets import make_classification X,y=make_classification(n_samples=1000, n_features=2,n_informative=1,n_redundant=0, n_clusters_per_class=1, random_state=1) X.shape, y.shape ((1000, 2), (1000,)) ytr[:10] array([0, 0, 0, 0, 1, 0, 1, 0, 0, 0]) 위 데이터를 모델 생성을 위한 훈련데이터와 모델 검정을 위한 검정데이터로 구분하였습니다. from sklearn.model_selection import train_test_split Xtr, Xte, ytr, yte=train_test_split(X, y, test_size=0.3, random_state=2) 이진 분류기를 생성하기 위해 SGDClassifier() 클래스를 사용합니다. 확률적 경사하강법(Stochastic Gradient Descent)을 적용한 정규화된 선형 분류모델( 경사하강법 참조) 계산값 < 0 &rightarr; 0(Negative) 계산값 > 0 &rightarr; 1(Positive) from sklearn.linear_model i...