더북(TheBook)

그리고 classification_report 함수는 앞서 설명한 성능지표를 보여준다.

print( metrics.classification_report( y_test, predicted ) )

 

결과

[[ 3  82]
 [ 3 110]]
              precision  recall    f1-score   support
  
          -1       0.50    0.04       0.07         85
           1       0.57    0.97       0.72        113
  
    accuracy                          0.57        198
   macro avg       0.54    0.50       0.39        198
weighted avg       0.54    0.57       0.44        198

score 함수는 모델의 학습 데이터셋 또는 평가 세트의 정확도를 보여주는 백분율 지표다. 다음 결과의 경우 대략 56% 정확하다는 의미다.

print( model.score( X_test,y_test ) )

 

결과

0.5622895622895623