In the Highly automatic machine learning page, it is said the function like Classify and Predict will do things like automatic feature selection, impute missing data etc. How can we know what Mathematica actually do to the data, like what method is used for data imputation, how Mathematica select features etc?

And can we explicit define the method to use for pre-processing the data like imputation and feature selection and clean?


1 Answer 1


If you look into the ClassifierFunction object, you can get some idea of what are the pre-processing. Here is an example using MNIST:

resource = ResourceObject["MNIST"];
trainingData = ResourceData[resource, "TrainingData"];
data = RandomSample[trainingData, 100];
digit = Classify[data]

enter image description here

This object is an association and has several keys

(* {"Basic", "Input", "Output", "Combiner", "Decision", \
"Models", "Log"} *)

The preprocessings are in the input key. The preprocessing procedures are organized as preprocessors and processors. And they will be applied in sequence to the images before sending to the model unit.

opts = First@Options[digit];

enter image description here

In this example, the preprocessor converts the image into MLDataset which is an internal format. We can see what it does by applying the preprocessor to the image:

inputPrepro = opts["Input"]["Preprocessor"]
preprocessedInput = inputPrepro@Keys[data]

After the data is converted to MLDataset by the preprocessor, it will be passed through the processors, which is a sequence of processors. In this example, it contains three processors ImputeMissing, ConformImage and ImageExtractNumericalVector. We can take out the individual processors

inputPro = opts["Input"]["Processor"]
{pro1, pro2, pro3} = inputPro[[2]]["Processors"]

From the name we can almost guess what they do. But to see what it does exactly to the input image, we can take a single input image and apply them individually

  • $\begingroup$ Do you know what't the method of ImageExtractNumericalVector $\endgroup$ Commented Aug 27, 2017 at 13:44
  • $\begingroup$ @HyperGroups In this example, it just takes the pixel values in the image and is the same as Flatten[ImageData[]]. $\endgroup$ Commented Aug 27, 2017 at 15:59
  • $\begingroup$ Does it standardize the data? like ConformImage---ImageToNumericalVector---Standardize $\endgroup$ Commented Aug 28, 2017 at 1:13
  • $\begingroup$ @HyperGroups I'm not sure what you mean "standardized". In this example ImageExtractNumericalVector[img] == Flatten[ImageData[img]]. But you can always try to test yourself using the example in the answer. $\endgroup$ Commented Aug 28, 2017 at 2:06
  • $\begingroup$ Yes, I think you're right. Now, I think there is no Standardize in ImageExtractNumericalVector. If there is the process workflow information will be ConformImage---ImageExtractNumericalVector---Standardize $\endgroup$ Commented Aug 28, 2017 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.