From 25c68df0f42ed6fc6da9722b32a7a69456ca862e Mon Sep 17 00:00:00 2001 From: Natalia Date: Wed, 20 May 2020 21:23:56 +0200 Subject: [PATCH] commit_natalia --- .idea/DSZI.iml | 2 +- .idea/misc.xml | 2 +- Restaurant/Natalia/Nowy.csv | 100 ++++++++++++++++++++++++++++++++ Restaurant/Natalia/Tree_natalia | 54 +++++++++++++++++ Restaurant/Natalia/__init__.py | 0 5 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 Restaurant/Natalia/Nowy.csv create mode 100644 Restaurant/Natalia/Tree_natalia create mode 100644 Restaurant/Natalia/__init__.py diff --git a/.idea/DSZI.iml b/.idea/DSZI.iml index 0267347..252f3ef 100644 --- a/.idea/DSZI.iml +++ b/.idea/DSZI.iml @@ -5,7 +5,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index a2e120d..d209534 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/Restaurant/Natalia/Nowy.csv b/Restaurant/Natalia/Nowy.csv new file mode 100644 index 0000000..b3e0c52 --- /dev/null +++ b/Restaurant/Natalia/Nowy.csv @@ -0,0 +1,100 @@ +20,0,2,4,3,2 +57,0,8,2,1,2 +50,1,3,4,1,1 +51,1,6,1,1,1 +82,1,9,1,2,2 +73,1,5,4,3,2 +65,0,7,3,2,1 +16,1,9,2,3,1 +23,0,1,4,3,1 +74,0,10,3,1,1 +85,1,5,4,1,2 +35,0,2,1,2,1 +79,1,9,4,1,2 +56,0,7,2,1,2 +51,0,6,4,3,2 +13,1,8,1,3,1 +30,0,8,2,2,2 +50,0,5,5,1,2 +39,1,9,3,3,1 +20,0,7,5,3,1 +63,1,8,4,1,1 +74,1,2,1,3,1 +46,1,7,3,1,2 +52,0,5,3,3,1 +39,0,9,1,3,1 +14,1,4,1,3,2 +81,1,2,1,3,1 +79,0,10,4,1,2 +69,0,1,5,1,2 +87,1,3,4,3,2 +72,1,9,1,3,1 +85,0,5,4,1,2 +59,1,10,5,3,1 +32,1,8,1,3,1 +28,0,3,1,1,2 +77,0,10,3,1,1 +82,1,4,5,3,2 +30,0,9,1,3,2 +83,1,9,2,3,2 +88,1,2,3,2,1 +72,1,8,3,2,1 +87,1,9,2,2,2 +13,0,8,5,2,1 +47,0,6,3,1,2 +51,1,1,4,3,1 +27,0,4,5,2,2 +50,1,7,5,1,2 +16,1,2,4,2,2 +29,0,8,4,3,2 +80,1,2,3,2,1 +16,0,10,2,1,1 +76,0,4,4,3,2 +44,1,6,1,1,2 +63,0,5,2,2,2 +12,1,5,4,3,2 +73,1,1,5,1,2 +39,1,7,3,3,1 +10,0,8,3,1,2 +32,0,7,4,3,1 +32,0,8,1,2,1 +74,1,2,4,1,2 +77,1,9,1,3,1 +13,1,2,1,1,1 +61,0,10,1,1,2 +48,1,2,1,1,1 +11,0,4,5,3,1 +80,0,10,3,3,1 +33,0,9,5,3,2 +53,1,5,2,3,2 +56,0,10,2,2,2 +25,1,4,4,1,2 +27,0,8,3,3,2 +83,0,1,1,1,2 +49,0,4,3,2,2 +76,0,10,3,1,1 +40,0,1,5,2,2 +73,1,3,4,2,1 +19,1,2,4,2,2 +77,1,7,2,3,1 +52,0,5,4,3,2 +29,0,10,2,3,1 +28,1,5,1,3,2 +63,0,1,5,3,2 +84,1,4,2,1,2 +31,0,9,1,3,1 +46,1,3,5,1,1 +84,0,6,5,3,1 +30,0,7,1,2,2 +29,1,7,1,1,1 +46,1,5,3,3,2 +17,1,8,1,1,1 +37,0,10,4,2,1 +43,0,6,1,3,1 +57,1,6,1,2,2 +58,1,4,1,3,2 +59,0,1,4,3,1 +26,0,7,2,3,2 +43,0,2,1,3,1 +66,0,8,2,1,1 +85,1,2,1,2,2 diff --git a/Restaurant/Natalia/Tree_natalia b/Restaurant/Natalia/Tree_natalia new file mode 100644 index 0000000..d5bb46a --- /dev/null +++ b/Restaurant/Natalia/Tree_natalia @@ -0,0 +1,54 @@ +# Load libraries +import pandas as pd +from sklearn.tree import DecisionTreeClassifier # Import Decision Tree Classifier +from sklearn.model_selection import train_test_split # Import train_test_split function +from sklearn import metrics #Import scikit-learn metrics module for accuracy calculation +from sklearn.tree import export_graphviz +from sklearn.externals.six import StringIO +from IPython.display import Image +import pydotplus + +col_names = ['age', 'sex', 'fat', 'spicy', 'hungry', 'budget'] +# load dataset +pima = pd.read_csv("nazwa.csv", header=None, names=col_names) + +#split dataset in features and target variable +feature_cols = ['age', 'sex', 'fat', 'spicy'] +X = pima[feature_cols] # Features +y = pima.label # Target variable + +# Split dataset into training set and test set +X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=1) # 70% training and 30% test + +# Create Decision Tree classifer object +clf = DecisionTreeClassifier() + +# Train Decision Tree Classifer +clf = clf.fit(X_train,y_train) + +#Predict the response for test dataset +y_pred = clf.predict(X_test) + +# Model Accuracy, how often is the classifier correct? +print("Accuracy:",metrics.accuracy_score(y_test, y_pred)) + +dot_data = StringIO() +export_graphviz(clf, out_file=dot_data, + filled=True, rounded=True, + special_characters=True,feature_names = feature_cols,class_names=['0','1']) +graph = pydotplus.graph_from_dot_data(dot_data.getvalue()) +graph.write_png('food_tree.png') +Image(graph.create_png()) + + +# Create Decision Tree classifer object +clf = DecisionTreeClassifier(criterion="entropy", max_depth=3) + +# Train Decision Tree Classifer +clf = clf.fit(X_train,y_train) + +#Predict the response for test dataset +y_pred = clf.predict(X_test) + +# Model Accuracy, how often is the classifier correct? +print("Accuracy:",metrics.accuracy_score(y_test, y_pred)) \ No newline at end of file diff --git a/Restaurant/Natalia/__init__.py b/Restaurant/Natalia/__init__.py new file mode 100644 index 0000000..e69de29