우당탕탕 개발일지

[대기오염 예측모델 개발] 머신러닝 모델의 종류 본문

인공지능

[대기오염 예측모델 개발] 머신러닝 모델의 종류

민아당긴아 2024. 9. 28. 10:46

학과에서 주관하는 데이터 분석 경진대회를 참가하여 대기오염 예측모델을 개발하고있다.

머신러닝 분류모델 - 결정 트리

머신러닝 분류모델로 가장 유명한 거는 아무래도 결정 트리(DecisionTree)이다.

특성공학 없이, 단순히 6가지의 대기오염물질 농도로 결정 트리 모델을 만들어보았을 때 다음과 같았다.

결정 트리 모델에 하이퍼파라미터 튜닝을 진행해서 모델 성능을 높일 수도 있겠다.

그래서 일단 DecionTree 라이브러리를 사용해서 모델을 돌려보았다.

decision_tree = DecisionTreeClassifier(random_state=42) # 모델 생성
decision_tree.fit(X_train, y_train) # 모델 학습

y_pred = decision_tree.predict(X_test) # 테스트 데이터를 예측한 출력값

# 모델 평가
accuracy = accuracy_score(y_test, y_pred) # 정확도
conf_matrix = confusion_matrix(y_test, y_pred) # 혼동행렬ecision_tree = DecisionTreeClassifier(random_state=42) # 모델 생성
decision_tree.fit(X_train, y_train) # 모델 학습

y_pred = decision_tree.predict(X_test) # 테스트 데이터를 예측한 출력값

# 모델 평가
accuracy = accuracy_score(y_test, y_pred) # 정확도
conf_matrix = confusion_matrix(y_test, y_pred) # 혼동행렬
class_report = classification_report(y_test, y_pred) # 분류 보고서

# 결과 출력
print(f"Accuracy: {accuracy:.4f}")
print("Confusion Matrix:")
print(conf_matrix)
print("Classification Report:")
print(class_report)

0.9923의 정확도가 나왔다.

 

이 외의 머신러닝 분류모델

그래서 다양한 모델을 사용해보면서 어떤 모델이 이 데이터에 적합한지 파악해볼 예정이다.