-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateModelColorsRandomForest.py
More file actions
61 lines (44 loc) · 1.18 KB
/
CreateModelColorsRandomForest.py
File metadata and controls
61 lines (44 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
"""
Created on augost 2023
@author: Alfonso Blanco
"""
#######################################################################
# PARAMETERS
######################################################################
import time
#import cv2
import joblib
Ini=time.time()
import numpy as np
#import os
#import re
###########################################################
# MAIN
##########################################################
from sklearn.ensemble import RandomForestClassifier
arr=[]
arry=[]
arrname=[]
f=open("colors.csv","r")
Conta=0;
for linea in f:
Conta=Conta+1
lineadelTrain =linea.split(",")
linea_x =[]
z=2
for x in lineadelTrain:
z=z+1
if z==6: break
linea_x.append(int(lineadelTrain[z]))
arr.append(linea_x)
arry.append(int(Conta))
arrname.append(lineadelTrain[1])
X_train=np.array(arr)
# print(x)
Y_train=np.array(arry)
Name=np.array(arrname)
rf= RandomForestClassifier()
modelRf= rf.fit(X_train,Y_train)
joblib.dump(modelRf, "colors_random_forest.joblib")
#modelRf=joblib.load("colors_random_forest.joblib")