gpt4 book ai didi

Python 机器学习标签和特征

转载 作者:行者123 更新时间:2023-11-30 09:50:22 25 4
gpt4 key购买 nike

给定一个包含 10,000 个观测值和 50 个特征加一个标签的数据集,假设训练/测试比例为 75%/25%,X_train、y_train、X_test 和 y_test 的维度是多少?应该是吗

X_train:(2500, 50)
y_train: (2500, )
X_test: (7500, 50)
y_test: (7500, )

X_train: (7500, 50)
y_train: (7500, )
X_test: (2500, 50)
y_test: (2500, )

最佳答案

您可以通过 train_test_split 亲自查看来自sklearn:

import numpy as np
from sklearn.model_selection import train_test_split

n = 10000
p = 50
X = np.random.random((n,p))
y = np.random.randint(0,2,n)

test = 0.25
d = {}
d["X_train"], d["X_test"], d["y_train"], d["y_test"] = train_test_split(X,y,test_size=test)

for split in d:
print(split, d[split].shape)

X_train (7500, 50)
X_test (2500, 50)
y_train (7500,)
y_test (2500,)

关于Python 机器学习标签和特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46015464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com