93439


Python初心者で機械学習を使用した疫学研究をしていますが進め方が合っているかどうかもわからないです。現在、ハイパーパラメータ調整で躓いています。もしよければアドバイス、指摘をお願いします。

[code]

    import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt
    import seaborn as sns
    import csv
    csvfile = open('BioAsseT practice data5.csv')
    df = pd.read_csv("BioAsseT practice data5.csv")
    X=df.external
    y=df.total
    X.shape, y.shape
    ((103,), (103,))
    from sklearn.model_selection import train_test_split
    
    X_train_val, X_test, y_train_val, y_test=train_test_split(X,y, test_size=0.2,random_state=1)
    
    X_train, X_val, y_train, y_val, y_test=train_test_split(X_train_val, y_train_val, test_size=0.3, random_state=1)
    
[/code]

[code]

    ValueError                                Traceback (most recent call last)
    <ipython-input-39-3f9989894ee6> in <module>
    ----> 1 X_train, X_val,  y_train, y_val, y_test=train_test_split(X_train_val, y_train_val, test_size=0.3, random_state=1)
    
    ValueError: not enough values to unpack (expected 5, got 4)
    
[/code]


CC BY-SA 4.0
2023-01-18T07:30:39.777
93430
2023-01-18T11:28:16.383
2023-01-18T11:27:36.470
3060
56639
question
python 機械学習 google-colaboratory scikit-learn
scikit-learn の train_test_split でエラー: ValueError: not enough values to unpack (expected 5, got 4)


>
[code]

>     X_train, X_val, y_train, y_val, y_test=train_test_split(X_train_val,
> y_train_val, test_size=0.3, random_state=1)
>  
[/code]

上記は左辺の変数が1つ余分です。4つにしましょう。


CC BY-SA 4.0
2023-01-18T11:02:36.377
93439
2023-01-18T11:28:16.383
2023-01-18T11:28:16.383
3060
39819
93430
answer