commit_natalia

This commit is contained in:
Natalia 2020-05-20 21:23:56 +02:00
parent 1227058e70
commit 25c68df0f4
5 changed files with 156 additions and 2 deletions

View File

@ -5,7 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/Restaurant/Marta/venv" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.7" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.7 (projekt_sztuczna)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (projekt_sztuczna)" project-jdk-type="Python SDK" />
</project>

100
Restaurant/Natalia/Nowy.csv Normal file
View File

@ -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
1 20 0 2 4 3 2
2 57 0 8 2 1 2
3 50 1 3 4 1 1
4 51 1 6 1 1 1
5 82 1 9 1 2 2
6 73 1 5 4 3 2
7 65 0 7 3 2 1
8 16 1 9 2 3 1
9 23 0 1 4 3 1
10 74 0 10 3 1 1
11 85 1 5 4 1 2
12 35 0 2 1 2 1
13 79 1 9 4 1 2
14 56 0 7 2 1 2
15 51 0 6 4 3 2
16 13 1 8 1 3 1
17 30 0 8 2 2 2
18 50 0 5 5 1 2
19 39 1 9 3 3 1
20 20 0 7 5 3 1
21 63 1 8 4 1 1
22 74 1 2 1 3 1
23 46 1 7 3 1 2
24 52 0 5 3 3 1
25 39 0 9 1 3 1
26 14 1 4 1 3 2
27 81 1 2 1 3 1
28 79 0 10 4 1 2
29 69 0 1 5 1 2
30 87 1 3 4 3 2
31 72 1 9 1 3 1
32 85 0 5 4 1 2
33 59 1 10 5 3 1
34 32 1 8 1 3 1
35 28 0 3 1 1 2
36 77 0 10 3 1 1
37 82 1 4 5 3 2
38 30 0 9 1 3 2
39 83 1 9 2 3 2
40 88 1 2 3 2 1
41 72 1 8 3 2 1
42 87 1 9 2 2 2
43 13 0 8 5 2 1
44 47 0 6 3 1 2
45 51 1 1 4 3 1
46 27 0 4 5 2 2
47 50 1 7 5 1 2
48 16 1 2 4 2 2
49 29 0 8 4 3 2
50 80 1 2 3 2 1
51 16 0 10 2 1 1
52 76 0 4 4 3 2
53 44 1 6 1 1 2
54 63 0 5 2 2 2
55 12 1 5 4 3 2
56 73 1 1 5 1 2
57 39 1 7 3 3 1
58 10 0 8 3 1 2
59 32 0 7 4 3 1
60 32 0 8 1 2 1
61 74 1 2 4 1 2
62 77 1 9 1 3 1
63 13 1 2 1 1 1
64 61 0 10 1 1 2
65 48 1 2 1 1 1
66 11 0 4 5 3 1
67 80 0 10 3 3 1
68 33 0 9 5 3 2
69 53 1 5 2 3 2
70 56 0 10 2 2 2
71 25 1 4 4 1 2
72 27 0 8 3 3 2
73 83 0 1 1 1 2
74 49 0 4 3 2 2
75 76 0 10 3 1 1
76 40 0 1 5 2 2
77 73 1 3 4 2 1
78 19 1 2 4 2 2
79 77 1 7 2 3 1
80 52 0 5 4 3 2
81 29 0 10 2 3 1
82 28 1 5 1 3 2
83 63 0 1 5 3 2
84 84 1 4 2 1 2
85 31 0 9 1 3 1
86 46 1 3 5 1 1
87 84 0 6 5 3 1
88 30 0 7 1 2 2
89 29 1 7 1 1 1
90 46 1 5 3 3 2
91 17 1 8 1 1 1
92 37 0 10 4 2 1
93 43 0 6 1 3 1
94 57 1 6 1 2 2
95 58 1 4 1 3 2
96 59 0 1 4 3 1
97 26 0 7 2 3 2
98 43 0 2 1 3 1
99 66 0 8 2 1 1
100 85 1 2 1 2 2

View File

@ -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))

View File