亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

代碼在列的規范上引發錯誤

代碼在列的規范上引發錯誤

翻過高山走不出你 2024-01-04 16:46:14
當我運行模型時,我不斷收到以下值錯誤: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_(更糟糕的是,列順序已更改,因此您不能依賴原始數據中的列索引)。

查看完整回答
反對 回復 2024-01-04
  • 1 回答
  • 0 關注
  • 334 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號