• 카테고리

    질문 & 답변
  • 세부 분야

    딥러닝 · 머신러닝

  • 해결 여부

    해결됨

2.6 사이킷런으로 수행하는 타이타닉 생존자 예측 관련해서 질문 드립니다.

20.12.15 10:51 작성 조회수 243

0

import numpy as np

import pandas as pd

df = pd.read_csv("titanic_train.csv", index_col = 0)

df

x_data = df.drop(['Survived', 'Name', 'Ticket', 'Cabin', 'Embarked','SibSp','Parch','Pclass'],axis=1)

x_data

x_data['Sex_Con'] = x_data['Sex'].apply(lambda x: 0 if x == 'male' else 1)

x_data = x_data.drop('Sex', axis=1)

x_data[['Age']] = x_data[['Age']].fillna(value=x_data[['Age']].mean())

x_data

x_data[['Age']].isnull().sum()

x_data[['Fare']].isnull().sum()

y_data = df['Survived']

y_data

y_data.isnull().sum()

from sklearn.model_selection import train_test_split

from sklearn.tree import DecisionTreeClassifier

X_train, Y_train, X_test,Y_test = train_test_split(x_data, y_data, test_size=0.2, random_state=11)

dt_clf = DecisionTreeClassifier(random_state=11)

dt_clf.fit(X_train,Y_train)

df_pred = dt_clf.predict(X_test)

이렇게 했을시  ValueError: Unknown label type: 'continuous-multioutput'

라는 에러가 나는데요 도통 어디서 나는지를 모르겠네요;;

답변 3

·

답변을 작성해보세요.

0

해결이 되었다니 다행입니다. ^^

0

nayun oh님의 프로필

nayun oh

질문자

2020.12.16

아 제가 X_train, Y_train, X_test,Y_test  의 순서를 잘못했더라구요 ^^;;

0

안녕하십니까,

전체 오류 메시지를 보지 않고서는 답변이 어려울 것 같습니다. 전체 오류 메시지를 여기에 올려주시겠습니까?