pip install pycaret
conda create --name temp python=3.9
로 버전에 맞게 해줘야 함.df = pd.read_csv("your_path/data.csv")
from pycaret.classification import *
s = setup(data = df.iloc[:,:9], target='ltw', session_id=11)
setup()
: PyCaret에서 다른 함수를 실행하기 전에 설정 함수를 호출해야 함. 이 함수에는 data와 target이라는 두 가지 필수 파라미터. 다른 모든 파라미터는 선택 사항data
: 학습 데이터셋(독립, 종속 포함한 전체 데이터)target
: 종속변수session_id
: seed 고정, random_state
기능과 동일함. best = compare_models()
Recall
성능이 가장 좋은 모델을 고르자하면, sort = 'Recall'
을 지정해주면 됨. best
# 분류 결과값 확인
plot_model(best, plot = 'confusion_matrix')
# 변수 중요도 확인
plot_model(best, plot = 'feature')
prediction = predict_model(best, data =test_df.iloc[:,:8])
prediction
predict_model(model, test_data)
순으로 작성하면 됨. # 실제 데이터와 비교 (f1_score, accuary_score)
from sklearn.metrics import f1_score, accuracy_score
f1_score(prediction['prediction_label'], test_df.iloc[:,9])
accuracy_score(prediction['prediction_label'], test_df.iloc[:,9])
save_model(best, './model/ltw_model')
# 저장한 모델 불러오기
load = load_model('./model/ltw_model')
load['trained_model']
load['trained_model']
로 설정해야 함.