accord-net / framework

Machine learning, computer vision, statistics and general scientific computing for .NET
http://accord-framework.net
GNU Lesser General Public License v2.1
4.48k stars 1.99k forks source link

SURF with ID3 decision tree #768

Closed HadeelHassan closed 7 years ago

HadeelHassan commented 7 years ago

Hi I hope you fine I am making program for face recognition using Accord.net. the steps are as follow

  1. create Excel sheet containing the location of image in PC and its name and the ID number of each individual. I used 14 image for each individual for training phase.

  2. Extract bag of visual word for each image by BOW (50 or more clusters) in accord.net and consider them as input for learning phase

  3. the output is the ID number of each individual

  4. learn ID3 or KNN (input,output)

  5. insert Test dataset 5 image for each individual and make prediction for each test image and save results in new excel sheet Now, I have two problems:

  6. the accuracy for recognition rate is very low for decision tree ID3 it is 26% (51 individual,703 training image,292 test image, 14 image for each individual) and the time is 724404 ms for KNN the accuracy is 42% ( 51 individual,703 training image,290 test image, 14 image for each individual) and the time is 228371

  7. not all images in test set is acceptable an error is appearing for a lot of images as attached image and i don't know why?

    can any one help me fix these problems? is the result will be good if i use hashing

Thanks

cesarsouza commented 7 years ago

Hi @HadeelHassan,

Instead of ID3 or k-NN, have you tried using a SVM with a Chi-Square kernel?

Also, have you tried increasing or decreasing the number of clusters in your K-Means to see how it affects your result?

HadeelHassan commented 7 years ago

Hi @cesarsouza No i did not try SVM and i have no idea about Chi-Square kernal , but yes i have tried decreasing and increasing clusters in my K-means , when i increase it the result be beter but not the best and the time of processing is increase too, these results is gained with 50 clusters.

cesarsouza commented 7 years ago

If you would like to give SVMs a try, there is an example on how to create multi-class kernel SVMs at the bottom of this page (see second example). You can replace all places where it is written "Gaussian" by "ChiSquare" in order to create a chi-square SVM.

HadeelHassan commented 7 years ago

thank you very very much i will try them and let you know , thanks again

HadeelHassan commented 7 years ago

Hi @cesarsouza cesar I implemented Chi-square SVM on 15 training set and 15 testset for 15 indivisual with 100 cluster for BOW the result is 73% , it is good result with compare to my old one, but when i give 262 training image i get inner exception (One or more exceptions were thrown when teaching the machines. Please check the InnerException property of this AggregateException to discover what exactly caused this error.)and gave me these suggestions

  1. make sure data column names are correct
  2. make sure the index is not negative number
  3. make sure that the maximum index on the list is less than the list size please , can you tell me why this happend thanks
cesarsouza commented 7 years ago

Hi @HadeelHassan,

Please do as the exception says and check the inner exceptions in the .InnerException property of the AggregateException you are receiving.

When the exception window pops up in Visual Studio, click in the button that says "View details", "View more details", or something like this. Then, find the "InnerException" box and check what is written there.

Regards, Cesar

HadeelHassan commented 7 years ago

@cesarsouza
{"Index was outside the bounds of the array."}, this is the error inside details at Accord.MachineLearning.VectorMachines.Learning.SupportVectorLearningHelper.GetNumberOfInputs[TKernel,TInput](TKernel kernel, TInput[] x) in C:\Projects\Accord.NET\framework\Sources\Accord.MachineLearning\VectorMachines\Learning\SupportVectorLearningHelper.cs:line 77 at Accord.MachineLearning.VectorMachines.Learning.BaseSupportVectorClassification3.Learn(TInput[] x, Boolean[] y, Double[] weights) in C:\Projects\Accord.NET\framework\Sources\Accord.MachineLearning\VectorMachines\Learning\Base\BaseSupportVectorClassification.cs:line 328 at Accord.MachineLearning.OneVsOneLearning3.TrainBinaryMachine(TInput[] x, Int32[] y, Double[] weights, Int32 k, Int32 total, Int32& progress, Tuple2[] pairs, ConcurrentBag1 exceptions) in C:\Projects\Accord.NET\framework\Sources\Accord.MachineLearning\Multiclass\Learning\OneVsOneLearning.cs:line 243

when i checked lines numbers that gave by exception , they where for different bottoms

cesarsouza commented 7 years ago

I think you might have a class without training or testing samples. Please make sure you have enough training samples for all classes, that your class numbers start at 0, that the highest class label in your output vector corresponds to the number_of_classes - 1 and that there are no integers in this interval without any associated training samples.

HadeelHassan commented 7 years ago

yeeeeees @cesarsouza it is working, i gained 89% for (262 training set and 135 test set) for 19 individual and it is very fast 47749 ms for the all test set really you are my hero, thanks a lot cesar

cesarsouza commented 7 years ago

Cool! I am glad you got it working and that it worked so well for your task! If you could, please help spread the word about the framework in your company or university. Also if you do any publications based on it please also cite the framework in your papers too 😄

Also thanks again for opening the issue, I hope other people will also find it in the future and find our conversation useful to solve their own tasks.

Regards, Cesar

HadeelHassan commented 7 years ago

@cesarsouza sure i will , also i told my master friends about you and your library .thanks thanks and many thanks