메뉴 건너뛰기

목록
2023.03.27 15:09

코드검증용

profile
조회 수 17 댓글 0 예스잼 0 노잼 0

No Attached Image

import pandas as pd

import seaborn as sns

import numpy as np

import matplotlib.pyplot as plt 

 

train = pd.read_csv('train.csv')

test = pd.read_csv('test.csv')

 

train.columns

test.columns

 

plt.figure(figsize = (12,12))

sns.heatmap(data = train.corr(), annot =True)

 

train.isnull().sum()

 

# intensity 제거 

train = train.drop(['intensity'], axis =1)

 

def feature_change(train):

    # type

    train['type'] = train['type'].map({'white': 0, 'red' : 1})

    #sweetness

    train['sweetness'] = train['sweetness'].map({'dry': 0, 'off-dry' : 1, 'medium-sweet' : 2})

    return train

train = feature_change(train)

 

 

test = test.drop(['intensity'], axis = 1)

def feature_change(test):

    # type

    test['type'] = test['type'].map({'white': 0, 'red' : 1})

    #sweetness

    test['sweetness'] = test['sweetness'].map({'dry': 0, 'off-dry' : 1, 'medium-sweet' : 2})

    return test

test = feature_change(test)

 

# 이상치만 잘 다듬는다면... 

# 이 대회가 새로운 모델을 만들라는건 아니잖아? 

# 보는 눈(해석)이 중요하다 

train = train[train['density'] < 1.00128]

train = train[train['chlorides']< 0.3]

 

train.info()

train.shape

 

train = train.drop(['index'], axis = 1)

test = test.drop(['index'], axis = 1)

train_x = train.drop(columns=['quality'])

train_y = train['quality']

 

 

from sklearn.model_selection import train_test_split

train_x, val_x, train_y, val_y  = train_test_split(train_x, train_y, test_size=0.2, random_state=42)

 

print(train_x.shape)

print(val_x.shape)

print(train_y.shape)

print(val_y.shape)

 

from sklearn.ensemble import RandomForestClassifier

from sklearn.metrics import confusion_matrix

from sklearn.metrics import classification_report

 

model = RandomForestClassifier(n_estimators=375, max_depth=14, random_state=42)

model.fit(train.drop(columns='quality'),train['quality'])

 

y_pred = model.predict(val_x)

print(confusion_matrix(val_y, y_pred))

print(classification_report(val_y, y_pred))

 

submission = pd.read_csv('sample_submission.csv')

y_pred = model.predict(test)

submission['quality'] = y_pred

 

submission.to_csv('submission_labtop5.csv', index=False)

점검 필요

 

 


List of Articles
번호 제목 글쓴이 날짜 조회 수 추천
공지 수용소닷컴 이용약관 file asuka 2020.05.16 1344 1
1019 UMPC 수리 포기 또치면과락 2024.03.30 115 0
1018 뻑난 UMPC에 탑재된 ROM 또치면과락 2024.03.22 96 0
1017 구글콘솔개발자계정 해지당함 2 file 말랑이 2024.03.21 116 0
1016 채널과 버스를 헷갈려버렸다 1 또치면과락 2024.03.16 86 0
1015 고독한 벼락치기 또치면과락 2024.03.12 61 0
1014 내일 몰아서 공부할것 또치면과락 2024.03.10 57 0
1013 오늘의 공부 또치면과락 2024.03.07 54 0
1012 오늘 공부 안함 또치면과락 2024.03.05 53 0
1011 오늘의 공부 또치면과락 2024.03.04 43 0
1010 스프린트... 또치면과락 2024.03.04 65 0
1009 노트북에 우분투데스크탑깔앗는대 file 말랑이 2024.03.03 38 0
1008 이번주 목표 설정 또치면과락 2024.03.03 25 0
1007 쿠다랑 엔비디아 다 날리고 새로 까는 중 2 삼육두유 2024.03.01 56 0
1006 내일 워드프로세서 시험보러감 또치면과락 2024.02.28 42 0
1005 왜 힙이 느릴까... 또치면과락 2024.02.24 117 0
1004 필기시험 떨어짐 3 또치면과락 2024.02.21 129 0
1003 내일은 기출문제... 3년치 돌리기 2 말폭도 2024.02.18 143 0
1002 다이소 무선마우스 보드 file 말랑이 2024.02.18 110 0
1001 우분투 파티션 자동구성시 에러 말랑이 2024.02.17 101 0
1000 정보처리기사.. ADsP... 정보보안기사 1 말폭도 2024.02.13 80 0
목록
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 56 Next
/ 56