# How to know the internal pre-processing of automatic machine learning function Classify?

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?

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]


This object is an association and has several keys

Keys[First@digit]
(* {"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];
opts["Input"]


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

pro1@inputPrepro@Keys[data[[1]]]
pro2@pro1@inputPrepro@Keys[data[[1]]]
pro3@pro2@pro1@inputPrepro@Keys[data[[1]]]

• Do you know what't the method of ImageExtractNumericalVector – HyperGroups Aug 27 '17 at 13:44
• @HyperGroups In this example, it just takes the pixel values in the image and is the same as Flatten[ImageData[]]. – xslittlegrass Aug 27 '17 at 15:59
• Does it standardize the data? like ConformImage---ImageToNumericalVector---Standardize – HyperGroups Aug 28 '17 at 1:13
• @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. – xslittlegrass Aug 28 '17 at 2:06
• 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 – HyperGroups Aug 28 '17 at 4:07