Я пытался уменьшить размерность фрейма данных с помощью PCA, но когда я запускаю свою программу, она показывает две ошибки, имеют ли панды внутренние атрибуты? как я могу это исправить ??
ds = pd.read_csv('forestfires.csv')
y = ds['area']
X = ds.drop(columns=['month','day'])
#this eliminates anomalous data
clf = IsolationForest( behaviour = 'new', max_samples=100, random_state = 1, contamination= 'auto')
preds = clf.fit_predict(ds.drop(columns= ['month','day']))
anomalos = elimina(preds)
ds = ds.drop(anomalos,axis=0)
pca = PCA(n_components = 6)
principalComponents = pca.fit_transform(X)
print(type(principalComponents))
print(type(pd.DataFrame))
X = pd.DataFrame(data= principalComponents, columns = labels)
this is the errors that my program throws me:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\managers.py", line 1651, in create_block_manager_from_blocks
placement=slice(0, len(axes[0])))]
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\blocks.py", line 3095, in make_block
return klass(values, ndim=ndim, placement=placement)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\blocks.py", line 87, in __init__
'{mgr}'.format(val=len(self.values), mgr=len(self.mgr_locs)))
ValueError: Wrong number of items passed 6, placement implies 11
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "Regresion.py", line 120, in <module>
X = pd.DataFrame(data= principalComponents, columns = labels)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\frame.py", line 424, in __init__me.py", line 424, in __init__
copy=copy) ernals\construction.py", line 167, in init_ndarray
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\construction.py", line 167, in init_ndarray ernals\managers.py", line 1660, in create_block_manager_from_blocks
return create_block_manager_from_blocks([values], [columns, index])
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\managers.py", line 1691, in construction_errorernals\managers.py", line 1660, in create_block_manager_from_blocks
construction_error(tot_items, blocks[0].shape[1:], axes, e)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\managers.py", line 1691, in construction_error
passed, implied))
ValueError: Shape of passed values is (458, 6), indices imply (458, 11)