1
私は324行と35列のデータセットを持っています。なぜDictVectorizerは機能の数を変更するのですか?
X_train, X_test, y_train, y_test = train_test_split(tempCSV[feaure_names[0:34]], tempCSV[feaure_names[34]], test_size=0.2, random_state=32)
これはうまくいくようですが、X_trainとX_testの両方に34の機能があります。私はカテゴリ変数があるので、DictVectorizerでさらに変換を適用します。今
from sklearn.feature_extraction import DictVectorizer
vecS=DictVectorizer(sparse=False)
X_train=vecS.fit_transform(X_train.to_dict(orient='record'))
X_test=vecS.fit_transform(X_test.to_dict(orient='record'))
私はX_testにX_trainを比較し、前者は46点の特徴を持っており、これが起こる可能性があり、いくつかの可能な理由は何ですか後者は唯一の44を持っていますか?
ありがとうございます!それが機能しました。意味をなさない –