我正在使用feature_engine来填充缺失的值
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# from feature-engine
from feature_engine import missing_data_imputers as mdi
#Working with House Data and Feature Engine__Practice
cols_to_use = [
'BsmtQual', 'FireplaceQu', 'LotFrontage', 'MasVnrArea', 'GarageYrBlt',
]
data = pd.read_csv(r'C:\Users\HP\Desktop\Hash\kaggle\Housing Project/train.csv', usecols=cols_to_use)
我创建了一个mdi实例以适合我的数据
imputer = mdi.MeanMedianImputer(imputation_method='median')
imputer.fit(data)
但是在调用transform方法时,它返回一个TypeError,我找不到它发生的原因。
tmp = imputer.transform(data)
这是返回的错误
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-39-2f486acb96bd> in <module>
----> 1 tmp = imputer.transform(data)
~\Anaconda3\lib\site-packages\feature_engine\missing_data_imputers.py in transform(self, X)
103 # Ugly work around to import the docstring for Sphinx, otherwise none of this is necessary
104 def transform(self, X):
--> 105 X = super().transform(X)
106 return X
107
~\Anaconda3\lib\site-packages\feature_engine\base_transformers.py in transform(self, X)
35
36 # Check method fit has been called
---> 37 check_is_fitted(self)
38
39 # check that input is a dataframe
TypeError: check_is_fitted() missing 1 required positional argument: 'attributes'