[PYTHON] _1st day until good accuracy is obtained by Leaf Classification

Data Analysis Beginners decided to try Kaggle's Leaf Classification. (https://www.kaggle.com/c/leaf-classification/data)

First figure out the problem

problem

** 99 classification ** is performed from ** 192 features ** (margin1 ~ 64, shape1 ~ 64, texture1 ~ 64).

data set

+1584 images + features

What I thought, what I thought

** Isn't there less training data 10 for each data? ** **

→ It seems good to try increasing the data set by parallel movement. Let's write the code and see how much it looks like to move the one with the same label.

samelabel_leaf.py


lst = [0,316,905,1001,1124,1158,1269,1319,1449, 1503]#Index of images with the same label
for i,j in enumerate(lst):
    plt.subplot(2,5,i+1)
    plt.xticks([])
    plt.yticks([])
    plt.imshow(images[j], "gray")
スクリーンショット 2017-07-07 22.52.22.png

It's almost the same orientation, so it may not be a good idea to rotate it too much. I think it would be better to zoom in and out sparingly.

** What do you mean by 192 "features"? ** **

→ I don't understand the meaning of margin, shape, and texture, so I'll look it up.

[PLANT_LEAF_CLASSIFICATION Paper](https://www.researchgate.net/profile/Charles_Mallah/publication/266632357_Plant_Leaf_Classification_using_Probabilistic_Integration_of_Shape_Texture_and_Margin_Features/links/547072f40cf216f8cfa9f72c.

3.2 Leaves "It is important to classify a wide range of classes in a few examples of this problem. 』
Apparently, less is intentional.

4.1 Leaf Shape Feature "It is one-dimensional data that represents a two-dimensional area or a church. CCDC is a scale, translation, and rotation invariant shape descriptor. Finally, the vector is scaled to an appropriate size so that it has the same number of elements so that the calculation time can be shortened. 』
I'm not sure what it is,

The center of gravity of shape $ \ bar {x}, \ bar {y} $,

\bar{x}=\frac{\sum_{i=1}^{s}x_i}{s}, \bar{y}=\frac{\sum_{i=1}^{s}y_i}{s}

As

d_i = \sqrt{(x_i-\bar{x})^{2}+(y_i-\bar{y})^{2}}

d_i^{'}=\frac{d_i}{\sum_{i=1}^{s}d_i}

It seems that the average of the center of gravity is taken to indicate the degree of distance from the overall center of gravity.

4.2 Leaf Texture Feature "For each image, ** 1024 small windows are randomly selected **. Apply ** rotation-invariant Gabor filter ** to them. By changing the standard deviation of the center of gravity of the filter, ** 5 different scale filters ** are created. Each filter is collapsed with each window and the ** 4 features ** of that filter are calculated. After that, each of the 1024x20 feature vectors is assigned to 64 vectors. A histogram is constructed from the 1024 assigned vectors, and 64 feature vectors are given. 』
Perhaps small windows are small elements such as 5x5 cut out from the image, but ** I didn't know what that meant. ** **

4.3 Leaf Margin Feature "First, ** apply a median filter to the binary leaf image to smooth the image **. This allows the entire contour to be represented by m points, and for each of these ** points the corresponding points on the original contour are calculated. ** **

  1. ** Size **: Signed distance between smoothed margin point and original corresponding point
  2. ** Gradient **: Signed difference between current point and next point
  3. ** Curvature **: The angle between the previous point and the next point at the current point Two positive and negative features for each of the generate six feature discriptors for each window. The feature vector of the margin window is used to generate 64 features in the same way as 4.2. 』\

In other words d61e0c76dd87fe4126a47b5dfe250193.jpg It's like that.

Perhaps it is possible to recognize the contour by smoothing and as a result the margin can be recognized.

** There is a lot of data with different aspect ratios, what should I do? ** **

→ I thought about two things.

In the former case, ** for example, the data of an elongated image is likely to be recognized as a round leaf **, so the latter seems to be better.

** Image, isn't it big? ** **

I think this can be solved by making it smaller. Even though Mnist is classified into 10 classes, it is 28x28 and ** quite accurate **, so it seems okay to reduce it to some extent. → It seems that you can experiment and consider this in various sizes.

** So let's implement it from tomorrow. ** **

Recommended Posts

_1st day until good accuracy is obtained by Leaf Classification
_ 2nd day until good accuracy is obtained by Leaf Classification
_ 3rd day until good accuracy is obtained by Leaf Classification