Reputation: 469
Okay, so I'm learning how to use decision trees, and want to work with images. So i've read up how they work and I kinda need help as to proceed cause I couldn't find much material (I know im not looking in the right direction).
So I have many 8x8 images. So I have taken these images and flattened them and created vectors of 192 values. [8 * 8 * 3 (3 for rgb)]. I have labeled each image as per their rotation (0, 90, 180, 270). Having these 2 data, how can I build a decision tree to calculate the the impurity and the gini, to classify the images based on their rotation?
I have read up many examples of decision trees, but all of them have examples that are not related to images (have features like age, gender, etc).
I anyone could provide my with useful sources to read up on how to use DTs for image classification, or could guide me would be really helpful as I'm blank as to what I'm supposed to with the arrays that I have.
Thank you.
Upvotes: 1
Views: 8006
Reputation: 64
I've recently delved into a similar problem, working on the MNIST dataset using Decision Trees.
Most of the work was carried out using R, but the basics can be extrapolated to other platforms.
The data preparation you seem to have already carried out. Then it's a matter of training your decision trees to obtain a model for your Decision tree.
Decision tree to identify digits 0 to 9
The model describes which features will be analyzed to determine a split. In this case, each feature is one of your pixels. In this case, by looking at the intensity of one pixel, the decision tree is able to determine whether it's a 1 or not. The accuracy is not very good, and for some digits appalling, but if simplicity is what you're after, then it can give you acceptable results, especially if you're willing to work with complex decision trees.
The code sample in this link would allow you to import the data to R, create a model and test it.
You can check the logs of the project, specifically the one referring to Introduction and Minimum Model in the links below.
https://hackaday.io/project/170591/log/175226-introduction https://hackaday.io/project/170591/log/175221-minimum-model
Upvotes: 2
Reputation: 105
Every dimension of your vector becomes features.
The feature in the example you mention are like age, gender, etc..
The feature in your problem is every dimension i.e. you have 192 features.
The decision tree would choose the best feature according to which to classify your image so that the overall entropy reduces.
But I would not recommend usage of Decision Tree for Image classification.
The best thing to use would be a Neural Networks say a CNN(convolution neural networks) but you can start with simple ones too. I would suggest you read this article. https://www.analyticsvidhya.com/blog/2019/01/build-image-classification-model-10-minutes/
Upvotes: 1