當我運行模型時,我不斷收到以下值錯誤:ValueError: Specifying the columns using strings is only supported for pandas DataFrames這是錯誤的完整版本:Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/sklearn/utils/__init__.py", line 425, in _get_column_indices all_columns = X.columnsAttributeError: 'numpy.ndarray' object has no attribute 'columns'During handling of the above exception, another exception occurred:Traceback (most recent call last): File "/home/user/Python Practice/Working/Playstore/untitled0.py", line 48, in <module> run.fit(x,y) File "/usr/lib/python3.8/site-packages/sklearn/pipeline.py", line 330, in fit Xt = self._fit(X, y, **fit_params_steps) File "/usr/lib/python3.8/site-packages/sklearn/pipeline.py", line 292, in _fit X, fitted_transformer = fit_transform_one_cached( File "/usr/lib/python3.8/site-packages/joblib/memory.py", line 352, in __call__ return self.func(*args, **kwargs) File "/usr/lib/python3.8/site-packages/sklearn/pipeline.py", line 740, in _fit_transform_one res = transformer.fit_transform(X, y, **fit_params) File "/usr/lib/python3.8/site-packages/sklearn/compose/_column_transformer.py", line 529, in fit_transform self._validate_remainder(X) File "/usr/lib/python3.8/site-packages/sklearn/compose/_column_transformer.py", line 327, in _validate_remainder cols.extend(_get_column_indices(X, columns)) File "/usr/lib/python3.8/site-packages/sklearn/utils/__init__.py", line 427, in _get_column_indices raise ValueError("Specifying the columns using strings is only "ValueError: Specifying the columns using strings is only supported for pandas DataFrames關于如何修復它有什么想法嗎?如果您需要的話,可以在這里找到所使用的數據。最初,我嘗試在單個變壓器變量下一次性執行所有列轉換,但這不起作用,建議我在再次運行之前將它們分開。我這樣做了,但結果如你所見。我需要一些幫助。謝謝你!
1 回答

Helenr
TA貢獻1780條經驗 獲得超4個贊
我不會像這樣分離柱變壓器。這樣,在您的run
管道中,第一個ColumnTransformer
?col
將 pandas 數據幀的輸入轉換為 numpy 數組。但是,列名稱無法被挑選出來cb_
(更糟糕的是,列順序已更改,因此您不能依賴原始數據中的列索引)。
添加回答
舉報
0/150
提交
取消