티스토리 뷰

import numpy as np
import pandas as pd
import json
from sklean.model_selection import train_test_split

with open('국민.json', 'r', encoding='UTF-8') as f:
  data=json.load(f)

sample_df=pd.DataFrame(data)

sample=sample_df.dropna()

sample=sample.astype('str')
y=sample.음주여부

X=sample.drop('음주여부', axis=1)
y.value_counts()

X_train, X_valid, y_train, y_valid = train_test_split(X,y,test_size=0.2,shuffle=True, random_state=120)

from sklearn.tree import DecisionTreeRegressor

dt=DecisionTreeRegressor(min_sample_split=3, max_depth=5, criterion='mae', splitter='best')

dt_model=dt.fit(X_train, y_train)
y_pred=dt.predict(X_valid)

from sklearn.metrics import mean_squrered_error

dt_mae=mean_squared_error(y_valid, y_pred)


극민json
{
"신장(5cm 단위)":{
    "0":"165,
    "1":"150"
  },
  "성별코드":{
    "0":"1",
    "1":"2"
  },
  "체중":{
    "0","60",
    "1":65
  },
  "음주여부":{
    "0":"0,0",
    "1":"1.0"
  }
}



}

'AICE(AI Certificate for Everyone) > AICE Associate' 카테고리의 다른 글

aice associate  (0) 2024.02.26
aice associate  (0) 2024.02.13
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함