0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

機械学習タスクを開始する際のデータ分割方法についてです。
機械学習タスクを進める際に、traintestの分け方,順番をミスる場合が多いので見返す用に書きました。

pip install scikit-learn
from sklearn.model_selection import train_test_split

# X: 特徴量, y: ターゲット変数
# test_size: テストデータの割合 (0.2 = 20%)
# random_state: 実行するたびに結果が変わらないよう固定するシード値
X_train, X_test, y_train, y_test = train_test_split(
    X,
    y,
    test_size=0.2,
    random_state=42
)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?