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]]]