Jeff Hernandez
Jeff Hernandez

Reputation: 2133

Impute missing values in Tensorflow?

I know about sklearn.preprocessing.Imputer but does Tensorflow have built-in functions to do this as well?

Upvotes: 4

Views: 7853

Answers (2)

Guille
Guille

Reputation: 755

In case your imputation cannot be the same for all entries as suggested before, you may want to use tensorflow-transform.

For example, if you want to use the mean or the median as the value to impute for the missing values in the corresponding entries, you can not do so with a default one as such values are dynamic and depend on the whole dataset (or a subset depending on your needs/rules).

Check out one of the examples on how you would do that in the official repository.

Upvotes: 5

kww
kww

Reputation: 549

As far as I know, there isn't a handy function that does the same thing as sklearn.preprocessing.Imputer.

There are a few ways of dealing with missing values using built-in functions:

  1. While reading in data: For example, you can set the default value for a missing value when reading in a CSV using the record_defaults field.
  2. If you have the data already: You can replace the nans using tf.where (example)

Upvotes: 1

Related Questions