我有一个具有260个独特观测值的数据集X
。>>
运行x_train,x_test,_,_=test_train_split(X,y,test_size=0.2)
时,我认为[p for p in x_test if p in x_train]
为空,但不是。事实证明,x_test
中只有两个观测值不在x_train
中。
是故意还是...?
编辑(发布了我正在使用的数据):
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split as split
import numpy as np
DATA=load_breast_cancer()
X=DATA.data
y= DATA.target
y=np.array([1 if p==0 else 0 for p in DATA.target])
x_train,x_test,y_train,y_test=split(X,y,test_size=0.2,stratify=y,random_state=42)
len([p for p in x_test if p in x_train]) #is not 0
我有一个具有260个独特观测值的数据集X。当运行x_train,x_test,_,_ = test_train_split(X,y,test_size = 0.2)时,我会假设[如果x_train中的p为x_test中的p,则p为p,但是为...
如果要避免这种行为,请不要使用: