4. 모든 입력 변수를 숫자로 변환하고 null 값을 0으로 채워 넣습니다.

    [in :]

    dataset=dataset.drop(columns=['NAME'])
    dataset= dataset.apply(pd.to_numeric, errors='coerce') 
    dataset.fillna(0, inplace=True)

    5. 데이터를 훈련 데이터와 테스트 데이터로 나눕니다.

    [in :]

    from sklearn.model_selection import train_test_split 
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)

    이로써 다음과 같은 4개의 데이터가 생성됩니다.

    X_train: 훈련 데이터셋의 특성

    X_test: 테스트 데이터셋의 특성

    y_train: 훈련 데이터셋의 라벨

    y_test: 테스트 데이터셋의 라벨

    데이터셋 준비가 끝났습니다. 이제 이를 이용해 세 가지 회귀 모델을 훈련하고 그 성능을 비교해 봅시다.

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.