使用 imputer.simple

attributes:

SimpleFill(fill_method=string)

return:array-type data has been filled

   parameters
Parameters Value Explain
fill_method 'mean', fill missing values with means accornd-ing its columns
'zero' fill with zero
'median' fill with columns' median
'min' fill with min value according per column
'random' fill with gaussian noise according to mean/std of column

example:

In [12]: from ycimpute.imputer import simple

In [13]: simple.SimpleFill(fill_method='mean').complete(boston_mis)
Out[13]:
array([[  6.32000000e-03,   1.80000000e+01,   2.31000000e+00, ...,
          1.53000000e+01,   3.96900000e+02,   4.98000000e+00],
       [  2.73100000e-02,   0.00000000e+00,   1.11807675e+01, ...,
          1.78000000e+01,   3.96900000e+02,   9.14000000e+00],
       [  2.72900000e-02,   1.08048246e+01,   7.07000000e+00, ...,
          1.84513158e+01,   3.92830000e+02,   1.25422368e+01],
       ...,
       [  6.07600000e-02,   0.00000000e+00,   1.19300000e+01, ...,
          2.10000000e+01,   3.96900000e+02,   5.64000000e+00],
       [  1.09590000e-01,   0.00000000e+00,   1.19300000e+01, ...,
          2.10000000e+01,   3.93450000e+02,   6.48000000e+00],
       [  4.74100000e-02,   0.00000000e+00,   1.19300000e+01, ...,
          2.10000000e+01,   3.96900000e+02,   7.88000000e+00]])

In [14]: simple.SimpleFill(fill_method='min').complete(boston_mis)
In [16]: simple.SimpleFill(fill_method='random').complete(boston_mis)

results matching ""

    No results matching ""