3회 기출유형 작업형 2 관련 질문
0
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요
먼저 유사한 질문이 있었는지 검색해보세요
import pandas as pd
import numpy as np
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import roc_auc_score, f1_score, accuracy_score
import sklearn
XY = pd.read_csv("https://raw.githubusercontent.com/lovedlim/inf/refs/heads/main/p4/3_2/train.csv")
X_result = pd.read_csv("https://raw.githubusercontent.com/lovedlim/inf/refs/heads/main/p4/3_2/test.csv")
#Employment Type, GraduateOrNot, FrequentFlyer,EverTravelledAbroad
X = XY.drop(columns = ['TravelInsurance'])
Y = XY['TravelInsurance']
total_X = pd.concat([X, X_result], axis = 0)
total_X['Employment Type'] = LabelEncoder().fit_transform(total_X['Employment Type'].astype(str))
total_X['GraduateOrNot'] = LabelEncoder().fit_transform(total_X['GraduateOrNot'].astype(str))
total_X['FrequentFlyer'] = LabelEncoder().fit_transform(total_X['FrequentFlyer'].astype(str))
total_X['EverTravelledAbroad'] = LabelEncoder().fit_transform(total_X['EverTravelledAbroad'].astype(str))
X = total_X.iloc[:len(X),:]
X_result = total_X.iloc[len(X):,:]
x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size = 0.2, random_state = 111)
model = RandomForestClassifier()
model.fit(x_train, y_train)
y_pred = model.predict(x_test)
roc_auc = roc_auc_score(y_pred, y_test)
f1 = f1_score(y_pred, y_test)
acc = accuracy_score(y_pred, y_test)
y_pred_result = model.predict(X_result)
pd.DataFrame({'index':X_result.index,'y_pred':y_pred_result}).to_csv('0000.csv', index = False)
print(pd.read_csv('0000.csv'))
안녕하세요, 혹시 이것도 답안으로 제출이 가능할지 한번 봐주실수있나요??
답변 1
수강 연장 문의드립니다.
0
32
2
강의 연장 문의
0
35
2
수강 신청 연장 문의드립니다.
0
49
2
작업형 1번문제... 환경관련
0
32
2
12회 기출은 언제 업데이트 될까요??
0
41
2
8/6 작성한 연장문의 질문글에 대한 재요청
0
39
2
수강기간 연장 문의
0
41
2
수강기간 연장문의
0
37
2
수강기간 연장 요청 문의드립니다
0
38
2
수강 기간 연장 문의
0
47
2
수강연장 가능 문의 (기간 약 한달반)
0
60
2
수강기간 연장 가능할까요 선생님
0
74
2
Section15. 수업에 사용하는 데이터 주소가 다 보이지 않아서 실습을 위한 데이터를 다운 받지 못하고 있습니다.
0
56
3
수강연장요청 문의
0
92
2
아무래도 다음 시험 연장은 어렵겠죠?
0
111
2
빅분기 12회 결과 관련 문의
0
114
1
책이랑 강의랑 순서나 예제가 다른것 같네요
0
83
2
수강연장 문의
0
107
2
재검토 요청 방법 좀 알려주셔요...-.-;;
0
108
2
12회 실기 질문(작업형 2)
0
94
2
뒤로가기 버튼 같은 것이 있나요?
0
68
1
강의 연장 문의
0
101
2
출력값 질문
0
74
2
수업노트가 어디에 있나요?
0
64
1





