Add competition files
This commit is contained in:
parent
80abd922b5
commit
81c1f1249c
22
competition/multi-class_example/MCclassifier.py
Normal file
22
competition/multi-class_example/MCclassifier.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
# 1. Importing new CSV data in pandas dataframes
|
||||||
|
import pandas as pd
|
||||||
|
data = pd.read_csv("iris_extension.csv")
|
||||||
|
|
||||||
|
# 2. Separating labels from data
|
||||||
|
y = data["label"]
|
||||||
|
data = data.drop(columns=["label"])
|
||||||
|
x = data.to_numpy()
|
||||||
|
|
||||||
|
# 3. Loading a trained model
|
||||||
|
import pickle
|
||||||
|
model = pickle.load(open('iris_classif_model.sav', 'rb'))
|
||||||
|
y_pred = model.predict(x)
|
||||||
|
|
||||||
|
# 4. Evaluating the model with the new data
|
||||||
|
from sklearn.metrics import classification_report, confusion_matrix
|
||||||
|
print("\n *************** MODEL EVALUATION ****************")
|
||||||
|
print("Confusion matrix:")
|
||||||
|
print(confusion_matrix(y, y_pred))
|
||||||
|
print(classification_report(y,y_pred))
|
||||||
|
|
||||||
36
competition/multi-class_example/MCmodel_trainer.py
Normal file
36
competition/multi-class_example/MCmodel_trainer.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
# 1. Importing CSV data for training in pandas dataframes
|
||||||
|
import pandas as pd
|
||||||
|
data = pd.read_csv("iris_base.csv")
|
||||||
|
|
||||||
|
# 2. Separating labels from data
|
||||||
|
y = data["label"]
|
||||||
|
data = data.drop(columns=["label"])
|
||||||
|
x = data.to_numpy()
|
||||||
|
|
||||||
|
# 3. Splitting data into training/test subsets for model training and validation
|
||||||
|
from sklearn.model_selection import train_test_split
|
||||||
|
x_train, x_test, y_train, y_test = train_test_split(data, y, test_size=0.2, stratify=y)
|
||||||
|
|
||||||
|
# 4. Fitting a Naive Gaussian classifier with the training split
|
||||||
|
from sklearn.naive_bayes import GaussianNB
|
||||||
|
gnb = GaussianNB()
|
||||||
|
gnb.fit(x_train,y_train)
|
||||||
|
|
||||||
|
# 5. The obtained model is tested with both the training and test split
|
||||||
|
# to ensure no underfitting and overfitting issues
|
||||||
|
y_pred_train = gnb.predict(x_train)
|
||||||
|
y_pred_test = gnb.predict(x_test)
|
||||||
|
from sklearn.metrics import classification_report, confusion_matrix
|
||||||
|
print("\n *************** TRAINING ****************")
|
||||||
|
print("\n Confusion matrix:")
|
||||||
|
print(confusion_matrix(y_train, y_pred_train))
|
||||||
|
print(classification_report(y_train,y_pred_train))
|
||||||
|
print("\n ************** VALIDATION ***************")
|
||||||
|
print("\n Confusion matrix:")
|
||||||
|
print(confusion_matrix(y_test, y_pred_test))
|
||||||
|
print(classification_report(y_test,y_pred_test))
|
||||||
|
|
||||||
|
# 6. Saving the obtained model
|
||||||
|
import pickle
|
||||||
|
pickle.dump(gnb, open('iris_classif_model.sav', 'wb'))
|
||||||
101
competition/multi-class_example/iris_base.csv
Normal file
101
competition/multi-class_example/iris_base.csv
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
,sepal.length,sepal.width,petal.length,petal.width,label
|
||||||
|
58,6.6,2.9,4.6,1.3,Versicolor
|
||||||
|
62,6.0,2.2,4.0,1.0,Versicolor
|
||||||
|
98,5.1,2.5,3.0,1.1,Versicolor
|
||||||
|
137,6.4,3.1,5.5,1.8,Virginica
|
||||||
|
54,6.5,2.8,4.6,1.5,Versicolor
|
||||||
|
83,6.0,2.7,5.1,1.6,Versicolor
|
||||||
|
56,6.3,3.3,4.7,1.6,Versicolor
|
||||||
|
119,6.0,2.2,5.0,1.5,Virginica
|
||||||
|
66,5.6,3.0,4.5,1.5,Versicolor
|
||||||
|
103,6.3,2.9,5.6,1.8,Virginica
|
||||||
|
148,6.2,3.4,5.4,2.3,Virginica
|
||||||
|
105,7.6,3.0,6.6,2.1,Virginica
|
||||||
|
45,4.8,3.0,1.4,0.3,Setosa
|
||||||
|
134,6.1,2.6,5.6,1.4,Virginica
|
||||||
|
47,4.6,3.2,1.4,0.2,Setosa
|
||||||
|
136,6.3,3.4,5.6,2.4,Virginica
|
||||||
|
92,5.8,2.6,4.0,1.2,Versicolor
|
||||||
|
111,6.4,2.7,5.3,1.9,Virginica
|
||||||
|
36,5.5,3.5,1.3,0.2,Setosa
|
||||||
|
21,5.1,3.7,1.5,0.4,Setosa
|
||||||
|
122,7.7,2.8,6.7,2.0,Virginica
|
||||||
|
42,4.4,3.2,1.3,0.2,Setosa
|
||||||
|
53,5.5,2.3,4.0,1.3,Versicolor
|
||||||
|
115,6.4,3.2,5.3,2.3,Virginica
|
||||||
|
17,5.1,3.5,1.4,0.3,Setosa
|
||||||
|
123,6.3,2.7,4.9,1.8,Virginica
|
||||||
|
132,6.4,2.8,5.6,2.2,Virginica
|
||||||
|
29,4.7,3.2,1.6,0.2,Setosa
|
||||||
|
141,6.9,3.1,5.1,2.3,Virginica
|
||||||
|
142,5.8,2.7,5.1,1.9,Virginica
|
||||||
|
40,5.0,3.5,1.3,0.3,Setosa
|
||||||
|
69,5.6,2.5,3.9,1.1,Versicolor
|
||||||
|
118,7.7,2.6,6.9,2.3,Virginica
|
||||||
|
7,5.0,3.4,1.5,0.2,Setosa
|
||||||
|
102,7.1,3.0,5.9,2.1,Virginica
|
||||||
|
39,5.1,3.4,1.5,0.2,Setosa
|
||||||
|
4,5.0,3.6,1.4,0.2,Setosa
|
||||||
|
5,5.4,3.9,1.7,0.4,Setosa
|
||||||
|
96,5.7,2.9,4.2,1.3,Versicolor
|
||||||
|
147,6.5,3.0,5.2,2.0,Virginica
|
||||||
|
91,6.1,3.0,4.6,1.4,Versicolor
|
||||||
|
26,5.0,3.4,1.6,0.4,Setosa
|
||||||
|
120,6.9,3.2,5.7,2.3,Virginica
|
||||||
|
3,4.6,3.1,1.5,0.2,Setosa
|
||||||
|
129,7.2,3.0,5.8,1.6,Virginica
|
||||||
|
73,6.1,2.8,4.7,1.2,Versicolor
|
||||||
|
48,5.3,3.7,1.5,0.2,Setosa
|
||||||
|
72,6.3,2.5,4.9,1.5,Versicolor
|
||||||
|
140,6.7,3.1,5.6,2.4,Virginica
|
||||||
|
107,7.3,2.9,6.3,1.8,Virginica
|
||||||
|
114,5.8,2.8,5.1,2.4,Virginica
|
||||||
|
27,5.2,3.5,1.5,0.2,Setosa
|
||||||
|
33,5.5,4.2,1.4,0.2,Setosa
|
||||||
|
88,5.6,3.0,4.1,1.3,Versicolor
|
||||||
|
95,5.7,3.0,4.2,1.2,Versicolor
|
||||||
|
28,5.2,3.4,1.4,0.2,Setosa
|
||||||
|
43,5.0,3.5,1.6,0.6,Setosa
|
||||||
|
37,4.9,3.6,1.4,0.1,Setosa
|
||||||
|
50,7.0,3.2,4.7,1.4,Versicolor
|
||||||
|
97,6.2,2.9,4.3,1.3,Versicolor
|
||||||
|
80,5.5,2.4,3.8,1.1,Versicolor
|
||||||
|
22,4.6,3.6,1.0,0.2,Setosa
|
||||||
|
9,4.9,3.1,1.5,0.1,Setosa
|
||||||
|
86,6.7,3.1,4.7,1.5,Versicolor
|
||||||
|
8,4.4,2.9,1.4,0.2,Setosa
|
||||||
|
146,6.3,2.5,5.0,1.9,Virginica
|
||||||
|
63,6.1,2.9,4.7,1.4,Versicolor
|
||||||
|
76,6.8,2.8,4.8,1.4,Versicolor
|
||||||
|
121,5.6,2.8,4.9,2.0,Virginica
|
||||||
|
38,4.4,3.0,1.3,0.2,Setosa
|
||||||
|
41,4.5,2.3,1.3,0.3,Setosa
|
||||||
|
16,5.4,3.9,1.3,0.4,Setosa
|
||||||
|
10,5.4,3.7,1.5,0.2,Setosa
|
||||||
|
99,5.7,2.8,4.1,1.3,Versicolor
|
||||||
|
85,6.0,3.4,4.5,1.6,Versicolor
|
||||||
|
110,6.5,3.2,5.1,2.0,Virginica
|
||||||
|
70,5.9,3.2,4.8,1.8,Versicolor
|
||||||
|
93,5.0,2.3,3.3,1.0,Versicolor
|
||||||
|
65,6.7,3.1,4.4,1.4,Versicolor
|
||||||
|
49,5.0,3.3,1.4,0.2,Setosa
|
||||||
|
108,6.7,2.5,5.8,1.8,Virginica
|
||||||
|
133,6.3,2.8,5.1,1.5,Virginica
|
||||||
|
12,4.8,3.0,1.4,0.1,Setosa
|
||||||
|
139,6.9,3.1,5.4,2.1,Virginica
|
||||||
|
143,6.8,3.2,5.9,2.3,Virginica
|
||||||
|
35,5.0,3.2,1.2,0.2,Setosa
|
||||||
|
138,6.0,3.0,4.8,1.8,Virginica
|
||||||
|
71,6.1,2.8,4.0,1.3,Versicolor
|
||||||
|
59,5.2,2.7,3.9,1.4,Versicolor
|
||||||
|
60,5.0,2.0,3.5,1.0,Versicolor
|
||||||
|
14,5.8,4.0,1.2,0.2,Setosa
|
||||||
|
44,5.1,3.8,1.9,0.4,Setosa
|
||||||
|
109,7.2,3.6,6.1,2.5,Virginica
|
||||||
|
117,7.7,3.8,6.7,2.2,Virginica
|
||||||
|
144,6.7,3.3,5.7,2.5,Virginica
|
||||||
|
112,6.8,3.0,5.5,2.1,Virginica
|
||||||
|
15,5.7,4.4,1.5,0.4,Setosa
|
||||||
|
79,5.7,2.6,3.5,1.0,Versicolor
|
||||||
|
55,5.7,2.8,4.5,1.3,Versicolor
|
||||||
|
94,5.6,2.7,4.2,1.3,Versicolor
|
||||||
|
51
competition/multi-class_example/iris_extension.csv
Normal file
51
competition/multi-class_example/iris_extension.csv
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
,sepal.length,sepal.width,petal.length,petal.width,label
|
||||||
|
82,5.8,2.7,3.9,1.2,Versicolor
|
||||||
|
31,5.4,3.4,1.5,0.4,Setosa
|
||||||
|
90,5.5,2.6,4.4,1.2,Versicolor
|
||||||
|
74,6.4,2.9,4.3,1.3,Versicolor
|
||||||
|
1,4.9,3.0,1.4,0.2,Setosa
|
||||||
|
81,5.5,2.4,3.7,1.0,Versicolor
|
||||||
|
20,5.4,3.4,1.7,0.2,Setosa
|
||||||
|
0,5.1,3.5,1.4,0.2,Setosa
|
||||||
|
101,5.8,2.7,5.1,1.9,Virginica
|
||||||
|
135,7.7,3.0,6.1,2.3,Virginica
|
||||||
|
19,5.1,3.8,1.5,0.3,Setosa
|
||||||
|
46,5.1,3.8,1.6,0.2,Setosa
|
||||||
|
23,5.1,3.3,1.7,0.5,Setosa
|
||||||
|
61,5.9,3.0,4.2,1.5,Versicolor
|
||||||
|
87,6.3,2.3,4.4,1.3,Versicolor
|
||||||
|
104,6.5,3.0,5.8,2.2,Virginica
|
||||||
|
51,6.4,3.2,4.5,1.5,Versicolor
|
||||||
|
11,4.8,3.4,1.6,0.2,Setosa
|
||||||
|
34,4.9,3.1,1.5,0.2,Setosa
|
||||||
|
127,6.1,3.0,4.9,1.8,Virginica
|
||||||
|
52,6.9,3.1,4.9,1.5,Versicolor
|
||||||
|
30,4.8,3.1,1.6,0.2,Setosa
|
||||||
|
57,4.9,2.4,3.3,1.0,Versicolor
|
||||||
|
75,6.6,3.0,4.4,1.4,Versicolor
|
||||||
|
149,5.9,3.0,5.1,1.8,Virginica
|
||||||
|
25,5.0,3.0,1.6,0.2,Setosa
|
||||||
|
78,6.0,2.9,4.5,1.5,Versicolor
|
||||||
|
131,7.9,3.8,6.4,2.0,Virginica
|
||||||
|
116,6.5,3.0,5.5,1.8,Virginica
|
||||||
|
89,5.5,2.5,4.0,1.3,Versicolor
|
||||||
|
126,6.2,2.8,4.8,1.8,Virginica
|
||||||
|
2,4.7,3.2,1.3,0.2,Setosa
|
||||||
|
113,5.7,2.5,5.0,2.0,Virginica
|
||||||
|
67,5.8,2.7,4.1,1.0,Versicolor
|
||||||
|
145,6.7,3.0,5.2,2.3,Virginica
|
||||||
|
64,5.6,2.9,3.6,1.3,Versicolor
|
||||||
|
68,6.2,2.2,4.5,1.5,Versicolor
|
||||||
|
13,4.3,3.0,1.1,0.1,Setosa
|
||||||
|
130,7.4,2.8,6.1,1.9,Virginica
|
||||||
|
18,5.7,3.8,1.7,0.3,Setosa
|
||||||
|
128,6.4,2.8,5.6,2.1,Virginica
|
||||||
|
124,6.7,3.3,5.7,2.1,Virginica
|
||||||
|
6,4.6,3.4,1.4,0.3,Setosa
|
||||||
|
24,4.8,3.4,1.9,0.2,Setosa
|
||||||
|
84,5.4,3.0,4.5,1.5,Versicolor
|
||||||
|
77,6.7,3.0,5.0,1.7,Versicolor
|
||||||
|
32,5.2,4.1,1.5,0.1,Setosa
|
||||||
|
125,7.2,3.2,6.0,1.8,Virginica
|
||||||
|
100,6.3,3.3,6.0,2.5,Virginica
|
||||||
|
106,4.9,2.5,4.5,1.7,Virginica
|
||||||
|
1154617
competition/training4tuplabeled.csv
Normal file
1154617
competition/training4tuplabeled.csv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user