image-pal-recog 0.1
ColorRecogniton app

To run scripts you should have installed libraries and pre-processed data file 'sample.csv'. 'sample.csv' is needed for fit Ml model. Scripts and Sample.csv must be in one catalog. 





script.py  

To run you should:
	python script.py 'url' 'number colors of pallete'

	Example: python script.py https://pma.childrensalon.com/media/product/0/d/0dd789c5-320117.jpg 3 


script2.py 

To run you should:
	python script2.py 'sample.csv' 'MlClassifier'

	Example: python script2.py sample.csv RandomForest


##########################################################################################################################################################################################################


We need sklearn to build ML models, pandas and numpy for data manipulation, cv2 and skimage to process images and get colors from them. We use plotly to display plots(jupyter notebook).

	####FEATURE ENGENIERING####

At first we have csv file from database, we read it, process and save info in new csv file(sample.csv). File contains palletes of main colors. This file will be used to fit ML models.

    #### ML #####
 Than we upload it using pandas, shuffle, split on train and test, do cross-validation, looking for best params and fit to one of ml models. The best choice is RandomForest, because that accuracy is about 75%, it is not bad.


data is 65890 rows 


 Sample is 1500 examples. 

1125 rows - test data
375 rows - train data



Best params for KNN: 

	Best leaf_size: 1
	Best p: 1
	Best n_neighbors: 12

KNN gives:

				precision    recall  f1-score   support

       beige       0.33      0.32      0.33        31
       black       0.28      0.57      0.38        23
        blue       0.59      0.57      0.58        23
       brown       0.28      0.41      0.33        22
        gold       0.33      0.28      0.30        29
       green       0.67      0.14      0.23        29
        grey       0.38      0.48      0.42        25
       ivory       0.27      0.47      0.34        17
      orange       0.80      0.55      0.65        29
        pink       0.50      0.46      0.48        26
      purple       0.50      0.42      0.45        24
         red       0.74      0.61      0.67        28
      silver       0.09      0.12      0.10        17
       white       0.61      0.61      0.61        28
      yellow       0.83      0.58      0.68        26

    accuracy                           0.44       377
   macro avg       0.48      0.44      0.44       377
weighted avg       0.50      0.44      0.45       377

Accuracy: 0.4403183023872679


Best params for RandomForest: 

 	'n_estimators': 500,
 	'min_samples_split': 10,
 	'min_samples_leaf': 1,
 	'max_depth': 10

RandomForest gives:

				precision    recall  f1-score   support

       beige       0.72      0.74      0.73        31
       black       0.69      0.78      0.73        23
        blue       0.67      0.87      0.75        23
       brown       0.75      0.82      0.78        22
        gold       0.73      0.83      0.77        29
       green       0.81      0.76      0.79        29
        grey       0.72      0.92      0.81        25
       ivory       0.62      0.47      0.53        17
      orange       0.88      0.76      0.81        29
        pink       0.79      0.73      0.76        26
      purple       0.84      0.67      0.74        24
         red       0.76      0.79      0.77        28
      silver       0.60      0.35      0.44        17
       white       0.81      0.79      0.80        28
      yellow       0.81      0.81      0.81        26

    accuracy                           0.75       377
   macro avg       0.75      0.74      0.74       377
weighted avg       0.76      0.75      0.75       377

Accuracy: 0.753315649867374


Best params for SVM: 

 	Best C : 1000
	Best gamma: 0.001
	Best kernel: rbf

SVM gives:

				precision    recall  f1-score   support

       beige       0.47      0.29      0.36        31
       black       0.52      0.48      0.50        23
        blue       0.37      0.43      0.40        23
       brown       0.19      0.50      0.27        22
        gold       0.58      0.52      0.55        29
       green       0.63      0.41      0.50        29
        grey       0.47      0.36      0.41        25
       ivory       0.31      0.47      0.37        17
      orange       0.74      0.48      0.58        29
        pink       0.57      0.62      0.59        26
      purple       0.55      0.50      0.52        24
         red       0.80      0.57      0.67        28
      silver       0.25      0.41      0.31        17
       white       0.60      0.64      0.62        28
      yellow       0.93      0.50      0.65        26

    accuracy                           0.48       377
   macro avg       0.53      0.48      0.49       377
weighted avg       0.55      0.48      0.50       377

Accuracy: 0.48010610079575594