在机器学习中降低我的预测数据数组的维度

问题描述 投票:0回答:0

我的数组 y_train 的当前形状是 (17,2)。有人告诉我,我的目标数据必须是一维的。由于我的特征数据 x_train 的形状为 (17,149),因此我必须将 y_train 减少为 (17,)。我不知道该怎么做,因为我是新手。

我试过这个:

X = df.loc[:,['Ethnicity',.....]

Y=df[['Status']]

new_x=ct.fit_transform(X)

X_train, X_test, y_train, y_test = train_test_split(new_x, new_y, test_size = 0.3, random_state=123)

svm_clf = svm.SVC(kernel = 'linear')

svm_clf.fit(X_train, y_train)

得到这个错误:

ValueError: y should be a 1d array, got an array of shape (17, 2) instead.

我的 X_train 形状是:

X_train.shape: (17, 149)

machine-learning svm dimensions dimensionality-reduction
© www.soinside.com 2019 - 2024. All rights reserved.