sklearn.impute.SimpleImputer(*, missing_values=nan, strategy='mean', fill_value=None, verbose='deprecated', copy=True, add_indicator=False)
通过简单的方法对缺失值进行补充
沿着每一列通过给定的策略(均值、中位数、众数)或定值对缺失值进行补充
int, float, str, np.nan, None or pandas.NA, default=np.nan
缺失值的占位符,数据中所有的值为missing_values
的空缺值将会被填充
str, default=’mean’
缺失值填补策略 | 填补缺失值的数值 |
---|---|
mean | 每一列的均值 |
median | 每一列的中位数(只能用于数值型数据) |
most_frequent | 每一列的众数(可用于数值型或字符串型数据) |
constant | 给定值fill_value |
str or numerical value, default=None
当参数strategy='constant'
时,将使用fill_value
替换所有缺失值
当该参数为default时,填补缺失值的时候,对于数值型数据将填补为0,对于字符串型或对象型数据将被填补为‘missing_value’
bool, default=True
array of shape (n_features,)
每个特征的缺失填补值
The imputation fill value for each feature
MissingIndicator
为缺失数值添加二元指标使用到的指标
Indicator used to add binary indicators for missing values.
int
拟合过程中的特征数量
ndarray of shape (n_features_in_,)
拟合过程中的特征名称
拟合数据
Fit the imputer on X.
拟合数据并将其进行转换
Fit to data, then transform it.
返回输出特征名称
Get output feature names for transformation.
返回模型参数
Get parameters for this estimator.
还原数据
Convert the data back to the original representation.
设置模型参数
Set the parameters of this estimator.
填补缺失值
Impute all missing values in X