0
緊隨着scikit-learn文檔,我正在試圖安裝一個虛擬classif9er。但是,在運行時會引發錯誤值。這是意想不到的,因爲之前我使用的是相同的數據:X = vector_data(一個稀疏矩陣),y = vector_target(一個int列表)與網格搜索cv擬合,沒有這樣的錯誤。Sklearn train_test_split創建1d數組
因此它必須引入train_test_split。
爲什麼在我的代碼中發生這種情況,而不是文檔,應該採取哪些預防措施?
X_train, X_test, y_train, y_test = train_test_split(vector_data, vector_target, random_state=0)
clf = DummyClassifier(strategy='stratified',random_state=0)
clf.fit(X_train, y_train)
clf.score(X_test,y_test)
DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19.
Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
DeprecationWarning)
什麼是'vector_data.shape','X_train.shape'和'X_test.shape'? – Psidom