LOOCV
(교차 유효성 검사 중 하나를 두십시오)을 사용하고있는 작은 데이터 세트를 가지고 있으므로 sklearn
에 있습니다.sklearn loocv.split이 작은 테스트와 열 배열을 예상보다 많이 반환했습니다.
"Number of labels=41 does not match number of samples=42"
: 내 분류를 실행하면
나는 다음과 같은 코드를 사용하여 테스트 및 훈련 세트를 생성 :
otu_trans = test_train.transpose()
# transpose otu table
merged = pd.concat([otu_trans, metadata[status]], axis=1, join='inner')
# merge phenotype column from metadata file with transposed otu table
X = merged.drop([status],axis=1)
# drop status from X
y = merged[status]
encoder = LabelEncoder()
y = pd.Series(encoder.fit_transform(y),
index=y.index, name=y.name)
# convert T and TF lables to 0 and 1 respectively
loocv = LeaveOneOut()
loocv.get_n_splits(X)
for train_index, test_index in loocv.split(X):
print("TRAIN:", train_index, "TEST:", test_index)
X_train, X_test = X[train_index], X[test_index]
y_train, y_test = y[train_index], y[test_index]
print(X_train, X_test, y_train, y_test)
내가 X_train
나는 그것이 있어야 생각대로 42,41
보다는 41,257
입니다 X_test
의 모양을 확인할 때, 따라서 데이터가 잘못된 축을 따라 분할 된 것처럼 보입니다.
아무도 왜 이런 일이 일어 났는지 설명 할 수 있습니까?
당신에게 모든
더 자세한 정보를 표시 할 수 있습니까? – pissall
@adamsorbie in X 얼마나 많은 샘플과 변수가 있습니까?초기 X 행렬의 모양은 무엇입니까? y 행렬에 대한 동일한 질문 – sera
42 샘플 및 257 피쳐가 있습니다. 즉 X.shape는 42,257을 반환하고 y.shape는 처음에 42를 반환합니다. 이 경우 X.shape를 분할 한 후 (41,257) 맞습니까? – adamsorbie