Rozpoczęcie prac nad drzewem decyzyjnym, budowa trainsetu
This commit is contained in:
parent
23a8321e2d
commit
8f1767c50f
37
package_location_classifier/classifier.py
Normal file
37
package_location_classifier/classifier.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from sklearn.tree import DecisionTreeClassifier, plot_tree, export_graphviz
|
||||||
|
from sklearn.externals.six import StringIO
|
||||||
|
from IPython.display import Image
|
||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
|
import pydotplus
|
||||||
|
from sklearn.model_selection import train_test_split
|
||||||
|
from sklearn import metrics
|
||||||
|
|
||||||
|
data = StringIO()
|
||||||
|
|
||||||
|
cols_names= ["product", "category", "temperature", "humidity", "chance_of_survive", "place_here"]
|
||||||
|
# import pdb
|
||||||
|
# pdb.set_trace()
|
||||||
|
products = pd.read_csv("trainset/trainset.csv", header=0, sep=",", names=cols_names)
|
||||||
|
feature_cols = ["category", "temperature", "humidity"]
|
||||||
|
|
||||||
|
X = pd.get_dummies(products[feature_cols])
|
||||||
|
y = products.place_here
|
||||||
|
dummies_names = X.columns.tolist()
|
||||||
|
|
||||||
|
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1, shuffle=True)
|
||||||
|
|
||||||
|
clf = DecisionTreeClassifier(criterion="entropy", ccp_alpha=0.02, max_features=4)
|
||||||
|
clf = clf.fit(X_train, y_train)
|
||||||
|
|
||||||
|
y_pred = clf.predict(X_test)
|
||||||
|
print("Correctly placed in : {} % of cases".format(
|
||||||
|
round(100 * metrics.accuracy_score(y_test, y_pred), 3)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
export_graphviz(clf, out_file=data, filled=True, rounded=True, special_characters=True, feature_names=dummies_names)
|
||||||
|
graph = pydotplus.graph_from_dot_data(data.getvalue())
|
||||||
|
graph.write_png('Ułożenie.png')
|
||||||
|
Image(graph.create_png())
|
250
package_location_classifier/trainset/trainset.csv
Normal file
250
package_location_classifier/trainset/trainset.csv
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
product,category,temperature,humidity,chance_of_survive,place_here
|
||||||
|
food,normal, 20, 0.5, 0.85, 1
|
||||||
|
food,normal,25, 0.7, 0.6, 0
|
||||||
|
electronic,keep_dry,20, 0.3, 0.95, 1
|
||||||
|
wood,normal,24, 0.5, 0.9, 1
|
||||||
|
electronic,keep_dry,25, 0.7, 0.4, 0
|
||||||
|
ammo,flammable,28, 0.4, 0.2, 0
|
||||||
|
ammo,flammable,27, 0.4, 0.25, 0
|
||||||
|
ammo,flammable,27, 0.6, 0.22, 0
|
||||||
|
ammo,flammable,22, 0.5, 0.8, 1
|
||||||
|
ammo,flammable,23, 0.5, 0.7, 0
|
||||||
|
clothes,keep_dry,25, 0.6, 0.4, 0
|
||||||
|
clothes,keep_dry,25, 0.7, 0.25, 0
|
||||||
|
clothes,keep_dry,25, 0.7, 0.25, 0
|
||||||
|
electronic,keep_dry,22,0.5,0.7,0
|
||||||
|
electronic,keep_dry,22,0.7,0.45,0
|
||||||
|
electronic,keep_dry,22,0.3,0.85,1
|
||||||
|
electronic,keep_dry,22,0.2,0.99,1
|
||||||
|
clothes,keep_dry,25, 0.7, 0.25, 0
|
||||||
|
clothes,keep_dry,25, 0.7, 0.25, 0
|
||||||
|
clothes,keep_dry,24, 0.2, 0.95, 0
|
||||||
|
frozen_food,freezed,24, 0.5, 0.001, 0
|
||||||
|
frozen_food,freezed,22, 0.5, 0.001, 0
|
||||||
|
frozen_food,freezed, 20, 0.5, 0.004, 0
|
||||||
|
frozen_food,freezed,-15, 0.3, 0.999, 1
|
||||||
|
frozen_food,freezed,-15, 0.2, 0.999, 1
|
||||||
|
frozen_food,freezed,-10, 0.3, 0.995, 1
|
||||||
|
frozen_food,freezed, -15, 0.2, 1.00, 1
|
||||||
|
frozen_food,freezed,24, 0.5, 0.001, 0
|
||||||
|
frozen_food,freezed,22, 0.5, 0.001, 0
|
||||||
|
frozen_food,freezed, 20, 0.5, 0.004, 0
|
||||||
|
frozen_food,freezed,-15, 0.3, 0.999, 1
|
||||||
|
frozen_food,freezed,-15, 0.2, 0.999, 1
|
||||||
|
frozen_food,freezed,-10, 0.3, 0.995, 1
|
||||||
|
frozen_food,freezed, -15, 0.2, 1.00, 1
|
||||||
|
frozen_food,freezed,24, 0.5, 0.001, 0
|
||||||
|
frozen_food,freezed,22, 0.5, 0.001, 0
|
||||||
|
frozen_food,freezed, 20, 0.5, 0.004, 0
|
||||||
|
frozen_food,freezed,-15, 0.3, 0.999, 1
|
||||||
|
frozen_food,freezed,-15, 0.2, 0.999, 1
|
||||||
|
frozen_food,freezed,-10, 0.3, 0.995, 1
|
||||||
|
frozen_food,freezed, -15, 0.2, 1.00, 1
|
||||||
|
clothes,keep_dry,28, 0.4, 0.7, 0
|
||||||
|
clothes,keep_dry, 22, 0.4, 0.95, 1
|
||||||
|
clothes,keep_dry, 21, 0.5, 0.5, 0
|
||||||
|
metal,normal,20, 0.3, 1, 1
|
||||||
|
metal,normal, 21, 0.3, 1, 1
|
||||||
|
metal,normal, -10, 0.3, 0.98, 1
|
||||||
|
metal,normal,28, 0.7, 0.9, 1
|
||||||
|
metal,normal,30, 0.7, 0.9, 1
|
||||||
|
wood,normal,25, 0.2, 0.98, 1
|
||||||
|
wood,normal,28, 0.7, 0.65, 0
|
||||||
|
books,keep_dry, 26, 0.7, 0.4, 0
|
||||||
|
books,keep_dry, 24, 0.5, 0.7, 0
|
||||||
|
books,keep_dry, 25, 0.3, 0.99, 1
|
||||||
|
books,keep_dry, 22, 0.4, 0.78, 0
|
||||||
|
books,keep_dry, 25, 0.35, 0.85, 1
|
||||||
|
books,keep_dry, 20, 0.2, 1, 1
|
||||||
|
drugs,keep_dry, 25, 0.5, 0.8, 0
|
||||||
|
drugs,keep_dry, 20, 0.3, 0.99, 1
|
||||||
|
drugs,keep_dry, 21, 0.3, 0.99, 1
|
||||||
|
drugs,keep_dry, 22, 0.7, 0.75, 0
|
||||||
|
drugs,keep_dry, 28, 0.3, 0.81, 0
|
||||||
|
drugs,keep_dry, 23, 0.3, 0.88, 1
|
||||||
|
drugs,keep_dry, 21, 0.37, 0.90, 1
|
||||||
|
glass,fragile, 20, 0.7, 0.995, 1
|
||||||
|
glass,fragile, -15, 0.3, 0.7, 0
|
||||||
|
vials,fragile, -15, 0.3, 0.75, 0
|
||||||
|
vials,fragile, 20, 0.5, 0.92, 1
|
||||||
|
plate,fragile, 25, 0.3, 1, 1
|
||||||
|
phials,fragile, 25, 0.5, 0.999, 1
|
||||||
|
cardboard,keep_dry, 22, 0.3, 0.999, 1
|
||||||
|
cardboard,keep_dry, 23, 0.7, 0.5, 0
|
||||||
|
cardboard,keep_dry, 28, 0.7, 0.4, 0
|
||||||
|
cardboard,keep_dry, 28, 0.5, 0.55, 0
|
||||||
|
cardboard,keep_dry, 25, 0.7, 0.45, 0
|
||||||
|
cardboard,keep_dry, 27, 0.3, 0.9, 1
|
||||||
|
cardboard,keep_dry, 29, 0.3, 0.88, 1
|
||||||
|
cardboard,keep_dry, 24, 0.4, 0.8, 1
|
||||||
|
frozen food,freezed, 20, 0.4, 0.001, 0
|
||||||
|
seeds,freezed, 25, 0.5, 0.2, 0
|
||||||
|
seeds,freezed, 20, 0.8, 0.01, 0
|
||||||
|
seeds,freezed, -10, 0.3, 0.998, 1
|
||||||
|
seeds,freezed, 20, 0.3, 0.6, 0
|
||||||
|
seeds,freezed, -8, 0.3, 0.99, 1
|
||||||
|
seeds,freezed, -10, 0.5, 0.995, 1
|
||||||
|
seeds,freezed, -15, 0.3, 1, 1
|
||||||
|
seeds,freezed, -15, 0.4, 1, 1
|
||||||
|
frozen food,freezed,-15, 0.3, 1, 1
|
||||||
|
frozen food,freezed,-15, 0.3, 1, 1
|
||||||
|
frozen food,freezed,-15, 0.3, 1, 1
|
||||||
|
frozen food,freezed,-15, 0.3, 1, 1
|
||||||
|
frozen food,freezed,-14, 0.3, 1, 1
|
||||||
|
frozen food,freezed,-12, 0.3, 0.999, 1
|
||||||
|
frozen food,freezed,-10, 0.3, 0.99, 1
|
||||||
|
frozen food,freezed,20, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.3, 0.01, 0
|
||||||
|
frozen food,freezed,22, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,22, 0.2, 0.01, 0
|
||||||
|
frozen food,freezed,22, 0.4, 0.01, 0
|
||||||
|
frozen food,freezed,22, 0.7, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,24, 0.3, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,28, 0.3, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.3, 0.01, 0
|
||||||
|
frozen food,freezed,21, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.3, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,23, 0.3, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,22, 0.3, 0.01, 0
|
||||||
|
frozen food,freezed,25, 0.5, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.3, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.7, 0.01, 0
|
||||||
|
frozen food,freezed,20, 0.2, 0.01, 0
|
||||||
|
|
||||||
|
seeds,freezed, 25, 0.5, 0.2, 0
|
||||||
|
seeds,freezed, 20, 0.8, 0.01, 0
|
||||||
|
seeds,freezed, -10, 0.3, 0.998, 1
|
||||||
|
seeds,freezed, 20, 0.3, 0.6, 0
|
||||||
|
seeds,freezed, -8, 0.3, 0.99, 1
|
||||||
|
seeds,freezed, -10, 0.5, 0.995, 1
|
||||||
|
seeds,freezed, -15, 0.3, 1, 1
|
||||||
|
seeds,freezed, -15, 0.4, 1, 1
|
||||||
|
frozen food,freezed,22, 0.3, 0.00001, 0
|
||||||
|
porcelain,fragile,20, 0.3, 0.99, 1
|
||||||
|
porcelain,fragile,22, 0.5, 0.999, 1
|
||||||
|
cosmetics,normal,20, 0.3, 1, 1
|
||||||
|
cosmetics,normal,28, 0.7, 0.90, 1
|
||||||
|
cosmetics,normal,22, 0.5, 0.99, 1
|
||||||
|
plastic,normal,25, 0.7, 1, 1
|
||||||
|
plastic,normal,24, 0.7, 1, 1
|
||||||
|
plastic,normal,30, 0.4, 0.99, 1
|
||||||
|
plastic,normal, 28, 0.6, 1, 1
|
||||||
|
wood,normal,28,0.5,0.96,1
|
||||||
|
wood,normal,27,0.4,1,1
|
||||||
|
plastic,normal,30, 0.7, 0.985, 1
|
||||||
|
electronic,keep_dry, 25, 0.6, 0.6, 0
|
||||||
|
metal,normal, 22, 0.7, 0.99, 1
|
||||||
|
metal,normal, 30, 0.5, 0.999, 1
|
||||||
|
metal,normal, 25, 0.3, 1, 1
|
||||||
|
metal,normal, 24, 0.4, 1, 1
|
||||||
|
seeds,freezed, 25, 0.5, 0.2, 0
|
||||||
|
seeds,freezed, 20, 0.8, 0.01, 0
|
||||||
|
seeds,freezed, -10, 0.3, 0.998, 1
|
||||||
|
seeds,freezed, 20, 0.3, 0.6, 0
|
||||||
|
seeds,freezed, -8, 0.3, 0.99, 1
|
||||||
|
seeds,freezed, -10, 0.5, 0.995, 1
|
||||||
|
seeds,freezed, -15, 0.3, 1, 1
|
||||||
|
seeds,freezed, -15, 0.4, 1, 1
|
||||||
|
lacquer,flammable, 30, 0.3, 0.4, 0
|
||||||
|
lacquer,flammable, 28, 0.5, 0.6, 0
|
||||||
|
lacquer,flammable, 28, 0.4, 0.6, 0
|
||||||
|
lacquer,flammable, 29, 0.3, 0.45, 0
|
||||||
|
lacquer,flammable, 25, 0.6, 0.65, 0
|
||||||
|
lacquer,flammable, 24, 0.7, 0.89, 0
|
||||||
|
lacquer,flammable, 22, 0.6, 0.95, 1
|
||||||
|
lacquer,flammable, 20, 0.4, 1, 1
|
||||||
|
lacquer,flammable, 20, 0.7, 1, 1
|
||||||
|
lacquer,flammable, 21, 0.6, 0.99, 1
|
||||||
|
lacquer,flammable, 23, 0.4, 0.9, 0
|
||||||
|
lacquer,flammable, 26, 0.2, 0.6, 0
|
||||||
|
lacquer,flammable, 30, 0.2, 0.35, 0
|
||||||
|
lacquer,flammable, 30, 0.7, 0.35, 0
|
||||||
|
gasoline,flammable, 30, 0.4, 0.1, 0
|
||||||
|
gasoline,flammable, 30, 0.7, 0.1, 0
|
||||||
|
gasoline,flammable, 26, 0.5, 0.4, 0
|
||||||
|
gasoline,flammable, 25, 0.7, 0.5, 0
|
||||||
|
gasoline,flammable, 25, 0.2, 0.5, 0
|
||||||
|
gasoline,flammable, 21, 0.7, 0.99, 1
|
||||||
|
gasoline,flammable, 22, 0.5, 0.92, 1
|
||||||
|
gasoline,flammable, 22, 0.7, 0.93, 1
|
||||||
|
gasoline,flammable, 20, 0.5, 1, 1
|
||||||
|
gasoline,flammable, 20, 0.7, 1, 1
|
||||||
|
gasoline,flammable, 20, 0.4, 1, 1
|
||||||
|
plate,fragile, 20, 0.7, 1, 1
|
||||||
|
plate,fragie, 24, 0.3, 1, 1
|
||||||
|
plate,fragile, -15, 0.3, 0.6, 0
|
||||||
|
plate,fragile, -10, 0.3, 0.65, 0
|
||||||
|
vials,fragile, -15, 0.3, 0.6, 0
|
||||||
|
vials,fragile, 20, 0.7, 1, 1
|
||||||
|
vials,fragile, 20, 0.2, 1, 1
|
||||||
|
books,keep_dry, 20, 0.3, 1, 1
|
||||||
|
books,keep_dry, 20, 0.7, 0.79, 0
|
||||||
|
books,keep_dry, 25, 0.7, 0.75, 0
|
||||||
|
books,keep_dry, 25, 0.2, 0.99, 1
|
||||||
|
books,keep_dry, 28, 0.2, 0.9, 1
|
||||||
|
books,keep_dry, 28, 0.7, 0.2, 0
|
||||||
|
books,keep_dry, 28, 0.6, 0.25, 0
|
||||||
|
books,keep_dry, 26, 0.6, 0.28, 0
|
||||||
|
books,keep_dry,26, 0.2, 0.95, 1
|
||||||
|
cardboard,keep_dry, 28, 0.7, 0.15, 0
|
||||||
|
cardboard,keep_dry, 28, 0.2, 0.9, 1
|
||||||
|
cardboard,keep_dry, 25, 0.2, 0.95, 1
|
||||||
|
cardboard,keep_dry, 25, 0.6, 0.3, 0
|
||||||
|
cardboard,keep_dry, 25, 0.7, 0.2, 0
|
||||||
|
electronics,keep_dry, 21, 0.4, 0.999, 1
|
||||||
|
electronic,keep_dry, 21, 0.7, 0.68, 0
|
||||||
|
electronic,keep_dry, 29, 0.2, 0.998, 1
|
||||||
|
electronic,keep_dry, 29, 0.6, 0.45, 0
|
||||||
|
electronic,keep_dry, 29, 0.7, 0.35, 0
|
||||||
|
electronic,keep_dry, 25, 0.4, 0.82, 1
|
||||||
|
electronic,keep_dry, 25, 0.5, 0.70, 0
|
||||||
|
electronic,keep_dry, 25, 0.7, 0.5, 0
|
||||||
|
electronic,keep_dry, 28, 0.2, 0.995, 1
|
||||||
|
electronic,keep_dry, 28, 0.4, 0.81, 1
|
||||||
|
electronic,keep_dry, 28, 0.6, 0.5, 0
|
||||||
|
electronic,keep_dry, 28, 0.7, 0.4, 0
|
||||||
|
electronic,keep_dry, 28, 0.3, 0.93, 1
|
||||||
|
clothes,keep_dry, 28, 0.3, 0.95, 1
|
||||||
|
clothes,keep_dry, 28, 0.2, 0.999, 1
|
||||||
|
clothes,keep_dry, 28, 0.7, 0.3, 0
|
||||||
|
wood,normal, 27, 0.2, 1, 1
|
||||||
|
wood,normal, 27, 0.7, 0.95, 1
|
||||||
|
wood,normal, 25, 0.7, 0.96, 1
|
||||||
|
wood,normal, 20, 0.3, 1, 1
|
||||||
|
wood,normal, 23, 0.2, 1, 1
|
||||||
|
wood,normal, 23, 0.7, 0.98, 1
|
||||||
|
electronic,keep_dry, 29, 0.6, 0.45, 0
|
||||||
|
electronic,keep_dry, 29, 0.7, 0.35, 0
|
||||||
|
electronic,keep_dry, 24, 0.4, 0.82, 1
|
||||||
|
electronic,keep_dry, 20, 0.5, 0.72, 0
|
||||||
|
electronic,keep_dry, 25, 0.7, 0.5, 0
|
||||||
|
electronic,keep_dry, 28, 0.2, 0.995, 1
|
||||||
|
electronic,keep_dry, 28, 0.4, 0.81, 1
|
||||||
|
electronic,keep_dry, 28, 0.6, 0.5, 0
|
||||||
|
electronic,keep_dry, 30, 0.7, 0.35, 0
|
||||||
|
electronic,keep_dry, 28, 0.3, 0.93, 1
|
||||||
|
clothes,keep_dry, 28, 0.3, 0.95, 1
|
||||||
|
clothes,keep_dry, 28, 0.2, 0.999, 1
|
||||||
|
clothes,keep_dry, 28, 0.7, 0.3, 0
|
||||||
|
wood,normal, 27, 0.2, 1, 1
|
||||||
|
wood,normal, 27, 0.7, 0.95, 1
|
||||||
|
wood,normal, 25, 0.7, 0.96, 1
|
||||||
|
wood,normal, 20, 0.3, 1, 1
|
||||||
|
wood,normal, 23, 0.2, 1, 1
|
||||||
|
wood,normal, 23, 0.7, 0.98, 1
|
||||||
|
wood,normal,30,0.7,0.95,1
|
||||||
|
food,normal,28,0.5,0.7,0
|
||||||
|
food,normal,26,0.3,0.9,1
|
||||||
|
food,normal,22,0.3,0.99,1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ PRODUCT_TYPES = {
|
|||||||
"freezed": [
|
"freezed": [
|
||||||
"frozen food",
|
"frozen food",
|
||||||
"seeds",
|
"seeds",
|
||||||
"frozen liquids"
|
|
||||||
],
|
],
|
||||||
"fragile": [
|
"fragile": [
|
||||||
"glass",
|
"glass",
|
||||||
@ -22,7 +21,8 @@ PRODUCT_TYPES = {
|
|||||||
"cosmetics",
|
"cosmetics",
|
||||||
"wood",
|
"wood",
|
||||||
"metal",
|
"metal",
|
||||||
"plastic"
|
"plastic",
|
||||||
|
"food"
|
||||||
],
|
],
|
||||||
"flammable": [
|
"flammable": [
|
||||||
"gasoline",
|
"gasoline",
|
||||||
|
Loading…
Reference in New Issue
Block a user