Tree - Final?
This commit is contained in:
parent
0c34087424
commit
0c096589d7
3
.gitignore
vendored
3
.gitignore
vendored
@ -59,3 +59,6 @@ Pipfile
|
|||||||
Pipfile.lock
|
Pipfile.lock
|
||||||
decision_tree
|
decision_tree
|
||||||
decision_tree.pdf
|
decision_tree.pdf
|
||||||
|
Source.gv.pdf
|
||||||
|
Source.gv
|
||||||
|
decision_tree.txt
|
||||||
|
@ -5,35 +5,34 @@ import graphviz
|
|||||||
import os
|
import os
|
||||||
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz/bin/'
|
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz/bin/'
|
||||||
|
|
||||||
# Define the training dataset with 8 attributes and corresponding labels
|
#importing the dataset from the disk
|
||||||
|
train_data_m=np.genfromtxt("dataset/converted_dataset.csv", delimiter=",",skip_header=1);
|
||||||
#train_data_m = pd.read_csv("dataset.csv") #importing the dataset from the disk
|
|
||||||
train_data_m=np.genfromtxt("dataset.csv", delimiter=",",skip_header=1);
|
|
||||||
#print(train_data_m)
|
|
||||||
# print(train_data_m) #viewing some row of the dataset
|
|
||||||
|
|
||||||
# Separate the attributes and labels
|
# Separate the attributes and labels
|
||||||
#X_train = [data[:-1] for data in training_data]
|
|
||||||
#y_train = [data[-1] for data in training_data]
|
|
||||||
|
|
||||||
X_train = [data[:-1] for data in train_data_m]
|
X_train = [data[:-1] for data in train_data_m]
|
||||||
y_train = [data[-1] for data in train_data_m]
|
y_train = [data[-1] for data in train_data_m]
|
||||||
#X_train = pd.get_dummies(data[:-1] for data in train_data_m)
|
|
||||||
#print(X_train)
|
|
||||||
#print(y_train)
|
|
||||||
# Create the decision tree classifier using the ID3 algorithm
|
# Create the decision tree classifier using the ID3 algorithm
|
||||||
clf = tree.DecisionTreeClassifier(criterion='entropy')
|
clf = tree.DecisionTreeClassifier(criterion='entropy')
|
||||||
|
#clf = tree.DecisionTreeClassifier(criterion='gini')
|
||||||
|
|
||||||
# Train the decision tree on the training data
|
# Train the decision tree on the training data
|
||||||
clf.fit(X_train, y_train)
|
clf.fit(X_train, y_train)
|
||||||
|
|
||||||
# Visualize the trained decision tree
|
# Visualize the trained decision tree
|
||||||
dot_data = tree.export_graphviz(clf, out_file=None, feature_names=['Attr1', 'Attr2', 'Attr3', 'Attr4', 'Attr5', 'Attr6', 'Attr7'], class_names=['YES', 'NO'], filled=True)
|
tree_text = tree.export_text(clf,feature_names=['Battery Charge', 'Fullness', 'Ready orders', 'Waiting tables','Availability', 'Cleanliness', 'Error'])
|
||||||
|
with open('decision_tree.txt', 'w') as f:
|
||||||
|
f.write(tree_text) # Save the visualization as a text file
|
||||||
|
dot_data = tree.export_graphviz(clf, out_file=None, feature_names=['Battery Charge', 'Fullness', 'Ready orders', 'Waiting tables','Availability', 'Cleanliness', 'Error'], class_names=['NO', 'YES'], filled=True,rounded=True)
|
||||||
graph = graphviz.Source(dot_data)
|
graph = graphviz.Source(dot_data)
|
||||||
graph.render("decision_tree") # Save the visualization as a PDF file
|
graph.render("decision_tree") # Save the visualization as a PDF file
|
||||||
|
|
||||||
# Test the decision tree with a new example
|
# Test the decision tree with a new example
|
||||||
#new_example = [1, 0, 0, 1, 1, 0, 0, 1] # Example with 8 attributes
|
#Battery Charge,Fullness,Ready orders,Waiting tables,Availability,Cleanliness,Error
|
||||||
new_example = [2, 0, 0, 1, 1 ,2, 1] # Example with 8 attributes
|
new_example = [2, 0, 1, 1, 1 ,2, 0]
|
||||||
predicted_label = clf.predict([new_example])
|
predicted_label = clf.predict([new_example])
|
||||||
print("Predicted Label:", predicted_label[0])
|
if predicted_label[0]>0:
|
||||||
|
result="YES"
|
||||||
|
else:
|
||||||
|
result="NO"
|
||||||
|
print("Predicted Label:", result)
|
288
dataset.csv
288
dataset.csv
@ -1,288 +0,0 @@
|
|||||||
3,1,1,1,1,3,1,0
|
|
||||||
3,1,1,1,1,3,0,0
|
|
||||||
3,1,1,1,1,2,1,0
|
|
||||||
3,1,1,1,1,2,0,0
|
|
||||||
3,1,1,1,1,1,1,0
|
|
||||||
3,1,1,1,1,1,0,0
|
|
||||||
3,1,1,1,0,3,1,0
|
|
||||||
3,1,1,1,0,3,0,0
|
|
||||||
3,1,1,1,0,2,1,0
|
|
||||||
3,1,1,1,0,2,0,0
|
|
||||||
3,1,1,1,0,1,1,0
|
|
||||||
3,1,1,1,0,1,0,0
|
|
||||||
3,1,1,0,1,3,1,0
|
|
||||||
3,1,1,0,1,3,0,0
|
|
||||||
3,1,1,0,1,2,1,0
|
|
||||||
3,1,1,0,1,2,0,0
|
|
||||||
3,1,1,0,1,1,1,0
|
|
||||||
3,1,1,0,1,1,0,0
|
|
||||||
3,1,1,0,0,3,1,0
|
|
||||||
3,1,1,0,0,3,0,0
|
|
||||||
3,1,1,0,0,2,1,0
|
|
||||||
3,1,1,0,0,2,0,0
|
|
||||||
3,1,1,0,0,1,1,0
|
|
||||||
3,1,1,0,0,1,0,0
|
|
||||||
3,1,0,1,1,3,1,0
|
|
||||||
3,1,0,1,1,3,0,0
|
|
||||||
3,1,0,1,1,2,1,0
|
|
||||||
3,1,0,1,1,2,0,0
|
|
||||||
3,1,0,1,1,1,1,0
|
|
||||||
3,1,0,1,1,1,0,0
|
|
||||||
3,1,0,1,0,3,1,0
|
|
||||||
3,1,0,1,0,3,0,0
|
|
||||||
3,1,0,1,0,2,1,0
|
|
||||||
3,1,0,1,0,2,0,0
|
|
||||||
3,1,0,1,0,1,1,0
|
|
||||||
3,1,0,1,0,1,0,0
|
|
||||||
3,1,0,0,1,3,1,0
|
|
||||||
3,1,0,0,1,3,0,0
|
|
||||||
3,1,0,0,1,2,1,0
|
|
||||||
3,1,0,0,1,2,0,0
|
|
||||||
3,1,0,0,1,1,1,0
|
|
||||||
3,1,0,0,1,1,0,0
|
|
||||||
3,1,0,0,0,3,1,0
|
|
||||||
3,1,0,0,0,3,0,0
|
|
||||||
3,1,0,0,0,2,1,0
|
|
||||||
3,1,0,0,0,2,0,0
|
|
||||||
3,1,0,0,0,1,1,0
|
|
||||||
3,1,0,0,0,1,0,0
|
|
||||||
3,0,1,1,1,3,1,0
|
|
||||||
3,0,1,1,1,3,0,0
|
|
||||||
3,0,1,1,1,2,1,0
|
|
||||||
3,0,1,1,1,2,0,0
|
|
||||||
3,0,1,1,1,1,1,0
|
|
||||||
3,0,1,1,1,1,0,0
|
|
||||||
3,0,1,1,0,3,1,0
|
|
||||||
3,0,1,1,0,3,0,0
|
|
||||||
3,0,1,1,0,2,1,0
|
|
||||||
3,0,1,1,0,2,0,0
|
|
||||||
3,0,1,1,0,1,1,0
|
|
||||||
3,0,1,1,0,1,0,0
|
|
||||||
3,0,1,0,1,3,1,0
|
|
||||||
3,0,1,0,1,3,0,0
|
|
||||||
3,0,1,0,1,2,1,0
|
|
||||||
3,0,1,0,1,2,0,0
|
|
||||||
3,0,1,0,1,1,1,0
|
|
||||||
3,0,1,0,1,1,0,0
|
|
||||||
3,0,1,0,0,3,1,0
|
|
||||||
3,0,1,0,0,3,0,0
|
|
||||||
3,0,1,0,0,2,1,0
|
|
||||||
3,0,1,0,0,2,0,0
|
|
||||||
3,0,1,0,0,1,1,0
|
|
||||||
3,0,1,0,0,1,0,0
|
|
||||||
3,0,0,1,1,3,1,0
|
|
||||||
3,0,0,1,1,3,0,0
|
|
||||||
3,0,0,1,1,2,1,0
|
|
||||||
3,0,0,1,1,2,0,1
|
|
||||||
3,0,0,1,1,1,1,0
|
|
||||||
3,0,0,1,1,1,0,1
|
|
||||||
3,0,0,1,0,3,1,0
|
|
||||||
3,0,0,1,0,3,0,0
|
|
||||||
3,0,0,1,0,2,1,0
|
|
||||||
3,0,0,1,0,2,0,0
|
|
||||||
3,0,0,1,0,1,1,0
|
|
||||||
3,0,0,1,0,1,0,0
|
|
||||||
3,0,0,0,1,3,1,0
|
|
||||||
3,0,0,0,1,3,0,0
|
|
||||||
3,0,0,0,1,2,1,0
|
|
||||||
3,0,0,0,1,2,0,1
|
|
||||||
3,0,0,0,1,1,1,0
|
|
||||||
3,0,0,0,1,1,0,1
|
|
||||||
3,0,0,0,0,3,1,0
|
|
||||||
3,0,0,0,0,3,0,0
|
|
||||||
3,0,0,0,0,2,1,1
|
|
||||||
3,0,0,0,0,2,0,1
|
|
||||||
3,0,0,0,0,1,1,1
|
|
||||||
3,0,0,0,0,1,0,1
|
|
||||||
2,1,1,1,1,3,1,0
|
|
||||||
2,1,1,1,1,3,0,0
|
|
||||||
2,1,1,1,1,2,1,0
|
|
||||||
2,1,1,1,1,2,0,0
|
|
||||||
2,1,1,1,1,1,1,0
|
|
||||||
2,1,1,1,1,1,0,0
|
|
||||||
2,1,1,1,0,3,1,0
|
|
||||||
2,1,1,1,0,3,0,0
|
|
||||||
2,1,1,1,0,2,1,0
|
|
||||||
2,1,1,1,0,2,0,0
|
|
||||||
2,1,1,1,0,1,1,0
|
|
||||||
2,1,1,1,0,1,0,0
|
|
||||||
2,1,1,0,1,3,1,0
|
|
||||||
2,1,1,0,1,3,0,0
|
|
||||||
2,1,1,0,1,2,1,0
|
|
||||||
2,1,1,0,1,2,0,0
|
|
||||||
2,1,1,0,1,1,1,0
|
|
||||||
2,1,1,0,1,1,0,0
|
|
||||||
2,1,1,0,0,3,1,0
|
|
||||||
2,1,1,0,0,3,0,0
|
|
||||||
2,1,1,0,0,2,1,0
|
|
||||||
2,1,1,0,0,2,0,0
|
|
||||||
2,1,1,0,0,1,1,0
|
|
||||||
2,1,1,0,0,1,0,0
|
|
||||||
2,1,0,1,1,3,1,0
|
|
||||||
2,1,0,1,1,3,0,0
|
|
||||||
2,1,0,1,1,2,1,0
|
|
||||||
2,1,0,1,1,2,0,0
|
|
||||||
2,1,0,1,1,1,1,0
|
|
||||||
2,1,0,1,1,1,0,0
|
|
||||||
2,1,0,1,0,3,1,0
|
|
||||||
2,1,0,1,0,3,0,0
|
|
||||||
2,1,0,1,0,2,1,0
|
|
||||||
2,1,0,1,0,2,0,0
|
|
||||||
2,1,0,1,0,1,1,0
|
|
||||||
2,1,0,1,0,1,0,0
|
|
||||||
2,1,0,0,1,3,1,0
|
|
||||||
2,1,0,0,1,3,0,0
|
|
||||||
2,1,0,0,1,2,1,0
|
|
||||||
2,1,0,0,1,2,0,0
|
|
||||||
2,1,0,0,1,1,1,0
|
|
||||||
2,1,0,0,1,1,0,0
|
|
||||||
2,1,0,0,0,3,1,0
|
|
||||||
2,1,0,0,0,3,0,0
|
|
||||||
2,1,0,0,0,2,1,0
|
|
||||||
2,1,0,0,0,2,0,0
|
|
||||||
2,1,0,0,0,1,1,0
|
|
||||||
2,1,0,0,0,1,0,0
|
|
||||||
2,0,1,1,1,3,1,0
|
|
||||||
2,0,1,1,1,3,0,0
|
|
||||||
2,0,1,1,1,2,1,0
|
|
||||||
2,0,1,1,1,2,0,0
|
|
||||||
2,0,1,1,1,1,1,0
|
|
||||||
2,0,1,1,1,1,0,0
|
|
||||||
2,0,1,1,0,3,1,0
|
|
||||||
2,0,1,1,0,3,0,0
|
|
||||||
2,0,1,1,0,2,1,0
|
|
||||||
2,0,1,1,0,2,0,0
|
|
||||||
2,0,1,1,0,1,1,0
|
|
||||||
2,0,1,1,0,1,0,0
|
|
||||||
2,0,1,0,1,3,1,0
|
|
||||||
2,0,1,0,1,3,0,0
|
|
||||||
2,0,1,0,1,2,1,0
|
|
||||||
2,0,1,0,1,2,0,0
|
|
||||||
2,0,1,0,1,1,1,0
|
|
||||||
2,0,1,0,1,1,0,0
|
|
||||||
2,0,1,0,0,3,1,0
|
|
||||||
2,0,1,0,0,3,0,0
|
|
||||||
2,0,1,0,0,2,1,0
|
|
||||||
2,0,1,0,0,2,0,0
|
|
||||||
2,0,1,0,0,1,1,0
|
|
||||||
2,0,1,0,0,1,0,0
|
|
||||||
2,0,0,1,1,3,1,0
|
|
||||||
2,0,0,1,1,3,0,0
|
|
||||||
2,0,0,1,1,2,1,0
|
|
||||||
2,0,0,1,1,2,0,1
|
|
||||||
2,0,0,1,1,1,1,0
|
|
||||||
2,0,0,1,1,1,0,1
|
|
||||||
2,0,0,1,0,3,1,0
|
|
||||||
2,0,0,1,0,3,0,0
|
|
||||||
2,0,0,1,0,2,1,0
|
|
||||||
2,0,0,1,0,2,0,0
|
|
||||||
2,0,0,1,0,1,1,0
|
|
||||||
2,0,0,1,0,1,0,0
|
|
||||||
2,0,0,0,1,3,1,0
|
|
||||||
2,0,0,0,1,3,0,0
|
|
||||||
2,0,0,0,1,2,1,0
|
|
||||||
2,0,0,0,1,2,0,1
|
|
||||||
2,0,0,0,1,1,1,0
|
|
||||||
2,0,0,0,1,1,0,1
|
|
||||||
2,0,0,0,0,3,1,0
|
|
||||||
2,0,0,0,0,3,0,0
|
|
||||||
2,0,0,0,0,2,1,1
|
|
||||||
2,0,0,0,0,2,0,1
|
|
||||||
2,0,0,0,0,1,1,1
|
|
||||||
2,0,0,0,0,1,0,1
|
|
||||||
1,1,1,1,1,3,1,0
|
|
||||||
1,1,1,1,1,3,0,0
|
|
||||||
1,1,1,1,1,2,1,0
|
|
||||||
1,1,1,1,1,2,0,0
|
|
||||||
1,1,1,1,1,1,1,0
|
|
||||||
1,1,1,1,1,1,0,0
|
|
||||||
1,1,1,1,0,3,1,0
|
|
||||||
1,1,1,1,0,3,0,0
|
|
||||||
1,1,1,1,0,2,1,0
|
|
||||||
1,1,1,1,0,2,0,0
|
|
||||||
1,1,1,1,0,1,1,0
|
|
||||||
1,1,1,1,0,1,0,0
|
|
||||||
1,1,1,0,1,3,1,0
|
|
||||||
1,1,1,0,1,3,0,0
|
|
||||||
1,1,1,0,1,2,1,0
|
|
||||||
1,1,1,0,1,2,0,0
|
|
||||||
1,1,1,0,1,1,1,0
|
|
||||||
1,1,1,0,1,1,0,0
|
|
||||||
1,1,1,0,0,3,1,0
|
|
||||||
1,1,1,0,0,3,0,0
|
|
||||||
1,1,1,0,0,2,1,0
|
|
||||||
1,1,1,0,0,2,0,0
|
|
||||||
1,1,1,0,0,1,1,0
|
|
||||||
1,1,1,0,0,1,0,0
|
|
||||||
1,1,0,1,1,3,1,0
|
|
||||||
1,1,0,1,1,3,0,0
|
|
||||||
1,1,0,1,1,2,1,0
|
|
||||||
1,1,0,1,1,2,0,0
|
|
||||||
1,1,0,1,1,1,1,0
|
|
||||||
1,1,0,1,1,1,0,0
|
|
||||||
1,1,0,1,0,3,1,0
|
|
||||||
1,1,0,1,0,3,0,0
|
|
||||||
1,1,0,1,0,2,1,0
|
|
||||||
1,1,0,1,0,2,0,0
|
|
||||||
1,1,0,1,0,1,1,0
|
|
||||||
1,1,0,1,0,1,0,0
|
|
||||||
1,1,0,0,1,3,1,0
|
|
||||||
1,1,0,0,1,3,0,0
|
|
||||||
1,1,0,0,1,2,1,0
|
|
||||||
1,1,0,0,1,2,0,0
|
|
||||||
1,1,0,0,1,1,1,0
|
|
||||||
1,1,0,0,1,1,0,0
|
|
||||||
1,1,0,0,0,3,1,0
|
|
||||||
1,1,0,0,0,3,0,0
|
|
||||||
1,1,0,0,0,2,1,0
|
|
||||||
1,1,0,0,0,2,0,0
|
|
||||||
1,1,0,0,0,1,1,0
|
|
||||||
1,1,0,0,0,1,0,0
|
|
||||||
1,0,1,1,1,3,1,0
|
|
||||||
1,0,1,1,1,3,0,0
|
|
||||||
1,0,1,1,1,2,1,0
|
|
||||||
1,0,1,1,1,2,0,0
|
|
||||||
1,0,1,1,1,1,1,0
|
|
||||||
1,0,1,1,1,1,0,0
|
|
||||||
1,0,1,1,0,3,1,0
|
|
||||||
1,0,1,1,0,3,0,0
|
|
||||||
1,0,1,1,0,2,1,0
|
|
||||||
1,0,1,1,0,2,0,0
|
|
||||||
1,0,1,1,0,1,1,0
|
|
||||||
1,0,1,1,0,1,0,0
|
|
||||||
1,0,1,0,1,3,1,0
|
|
||||||
1,0,1,0,1,3,0,0
|
|
||||||
1,0,1,0,1,2,1,0
|
|
||||||
1,0,1,0,1,2,0,0
|
|
||||||
1,0,1,0,1,1,1,0
|
|
||||||
1,0,1,0,1,1,0,0
|
|
||||||
1,0,1,0,0,3,1,0
|
|
||||||
1,0,1,0,0,3,0,0
|
|
||||||
1,0,1,0,0,2,1,0
|
|
||||||
1,0,1,0,0,2,0,0
|
|
||||||
1,0,1,0,0,1,1,0
|
|
||||||
1,0,1,0,0,1,0,0
|
|
||||||
1,0,0,1,1,3,1,0
|
|
||||||
1,0,0,1,1,3,0,0
|
|
||||||
1,0,0,1,1,2,1,0
|
|
||||||
1,0,0,1,1,2,0,0
|
|
||||||
1,0,0,1,1,1,1,0
|
|
||||||
1,0,0,1,1,1,0,0
|
|
||||||
1,0,0,1,0,3,1,0
|
|
||||||
1,0,0,1,0,3,0,0
|
|
||||||
1,0,0,1,0,2,1,0
|
|
||||||
1,0,0,1,0,2,0,0
|
|
||||||
1,0,0,1,0,1,1,0
|
|
||||||
1,0,0,1,0,1,0,0
|
|
||||||
1,0,0,0,1,3,1,0
|
|
||||||
1,0,0,0,1,3,0,0
|
|
||||||
1,0,0,0,1,2,1,0
|
|
||||||
1,0,0,0,1,2,0,0
|
|
||||||
1,0,0,0,1,1,1,0
|
|
||||||
1,0,0,0,1,1,0,0
|
|
||||||
1,0,0,0,0,3,1,0
|
|
||||||
1,0,0,0,0,3,0,0
|
|
||||||
1,0,0,0,0,2,1,0
|
|
||||||
1,0,0,0,0,2,0,0
|
|
||||||
1,0,0,0,0,1,1,0
|
|
||||||
1,0,0,0,0,1,0,0
|
|
|
201
dataset/Dataset.csv
Normal file
201
dataset/Dataset.csv
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Battery Charge,Fullness,Ready orders,Waiting tables,Availability,Cleanliness,Error,To go
|
||||||
|
high,full,none,none,available,low,yes,no
|
||||||
|
low,full,none,none,unavailable,medium,yes,no
|
||||||
|
high,full,none,none,unavailable,medium,no,no
|
||||||
|
medium,empty,none,none,unavailable,low,no,no
|
||||||
|
high,full,none,none,available,medium,no,no
|
||||||
|
low,full,none,available,unavailable,medium,yes,no
|
||||||
|
medium,empty,none,available,unavailable,high,yes,no
|
||||||
|
medium,full,none,available,available,low,yes,no
|
||||||
|
medium,full,available,none,unavailable,low,yes,no
|
||||||
|
high,empty,none,none,unavailable,medium,yes,no
|
||||||
|
medium,empty,none,available,unavailable,medium,yes,no
|
||||||
|
low,empty,available,none,available,high,no,no
|
||||||
|
high,full,available,none,available,low,yes,no
|
||||||
|
medium,full,none,available,available,low,no,no
|
||||||
|
medium,full,none,available,available,medium,no,yes
|
||||||
|
empty,full,none,none,unavailable,high,yes,no
|
||||||
|
low,full,none,none,unavailable,medium,no,no
|
||||||
|
low,full,available,none,unavailable,low,no,no
|
||||||
|
medium,empty,none,available,unavailable,medium,no,no
|
||||||
|
low,empty,available,available,unavailable,medium,no,no
|
||||||
|
medium,empty,available,available,unavailable,medium,yes,no
|
||||||
|
low,empty,none,none,unavailable,high,no,no
|
||||||
|
medium,full,available,available,unavailable,medium,yes,no
|
||||||
|
high,empty,available,none,available,medium,no,yes
|
||||||
|
empty,empty,available,available,unavailable,low,yes,no
|
||||||
|
high,empty,none,none,unavailable,high,yes,no
|
||||||
|
medium,empty,available,available,available,medium,no,yes
|
||||||
|
medium,full,available,available,available,low,no,no
|
||||||
|
empty,full,none,available,available,high,no,no
|
||||||
|
empty,empty,none,none,unavailable,low,no,no
|
||||||
|
medium,full,none,none,unavailable,medium,no,no
|
||||||
|
medium,empty,available,available,unavailable,high,yes,no
|
||||||
|
high,full,available,none,available,medium,yes,no
|
||||||
|
medium,empty,none,available,unavailable,low,yes,no
|
||||||
|
low,empty,none,none,available,low,no,no
|
||||||
|
high,full,available,available,available,low,yes,no
|
||||||
|
high,full,available,available,unavailable,high,yes,no
|
||||||
|
low,full,available,available,unavailable,high,yes,no
|
||||||
|
low,full,none,none,unavailable,low,yes,no
|
||||||
|
medium,full,none,none,unavailable,medium,yes,no
|
||||||
|
high,full,none,available,available,medium,yes,no
|
||||||
|
low,empty,none,none,unavailable,low,no,no
|
||||||
|
high,empty,available,none,unavailable,low,yes,no
|
||||||
|
medium,full,none,available,available,high,no,yes
|
||||||
|
low,empty,available,available,available,high,yes,no
|
||||||
|
low,full,available,none,unavailable,high,yes,no
|
||||||
|
medium,full,available,none,unavailable,low,no,no
|
||||||
|
medium,full,available,available,unavailable,high,no,no
|
||||||
|
medium,full,none,available,unavailable,low,yes,no
|
||||||
|
medium,empty,available,none,unavailable,low,yes,no
|
||||||
|
medium,empty,none,none,available,high,no,no
|
||||||
|
empty,full,none,none,available,low,no,no
|
||||||
|
low,full,available,available,available,medium,yes,no
|
||||||
|
low,full,available,none,unavailable,high,no,no
|
||||||
|
high,full,available,none,available,medium,no,no
|
||||||
|
low,full,none,available,available,medium,no,no
|
||||||
|
empty,empty,none,available,available,high,no,no
|
||||||
|
low,full,none,available,unavailable,low,no,no
|
||||||
|
high,full,none,none,unavailable,high,no,no
|
||||||
|
medium,full,none,none,available,high,yes,no
|
||||||
|
low,empty,none,available,available,medium,no,no
|
||||||
|
empty,empty,none,available,unavailable,low,no,no
|
||||||
|
empty,full,available,none,available,low,yes,no
|
||||||
|
empty,empty,available,available,available,medium,no,no
|
||||||
|
empty,empty,available,none,unavailable,medium,no,no
|
||||||
|
empty,empty,none,none,unavailable,high,no,no
|
||||||
|
medium,empty,available,none,unavailable,high,no,no
|
||||||
|
empty,empty,available,none,available,medium,yes,no
|
||||||
|
empty,empty,none,none,unavailable,high,yes,no
|
||||||
|
high,full,available,available,unavailable,low,no,no
|
||||||
|
high,empty,available,available,available,high,yes,no
|
||||||
|
high,empty,available,none,available,low,no,no
|
||||||
|
low,empty,none,available,unavailable,medium,no,no
|
||||||
|
medium,full,none,available,unavailable,low,no,no
|
||||||
|
medium,empty,none,available,available,high,yes,no
|
||||||
|
medium,empty,available,available,available,high,no,yes
|
||||||
|
high,empty,none,available,unavailable,low,yes,no
|
||||||
|
low,full,available,available,available,high,no,no
|
||||||
|
medium,empty,none,available,available,high,no,no
|
||||||
|
medium,empty,available,none,available,high,no,yes
|
||||||
|
empty,full,available,available,unavailable,high,no,no
|
||||||
|
low,empty,none,available,available,low,no,no
|
||||||
|
high,full,none,available,available,low,yes,no
|
||||||
|
high,empty,none,none,available,medium,yes,no
|
||||||
|
empty,empty,available,none,unavailable,low,no,no
|
||||||
|
high,full,none,available,unavailable,low,yes,no
|
||||||
|
empty,full,none,available,unavailable,high,no,no
|
||||||
|
empty,full,available,none,available,low,no,no
|
||||||
|
medium,full,none,none,available,high,no,no
|
||||||
|
medium,full,available,available,unavailable,low,yes,no
|
||||||
|
empty,full,available,available,unavailable,low,yes,no
|
||||||
|
low,empty,none,none,unavailable,medium,no,no
|
||||||
|
low,full,none,none,unavailable,low,no,no
|
||||||
|
low,full,available,available,unavailable,low,yes,no
|
||||||
|
low,empty,none,available,available,low,yes,no
|
||||||
|
empty,full,available,none,unavailable,high,no,no
|
||||||
|
low,full,available,none,available,high,no,no
|
||||||
|
high,full,available,available,available,medium,yes,no
|
||||||
|
empty,full,none,available,available,medium,yes,no
|
||||||
|
low,full,none,none,available,medium,no,no
|
||||||
|
empty,full,available,available,available,low,no,no
|
||||||
|
medium,full,available,none,unavailable,medium,yes,no
|
||||||
|
empty,empty,none,none,available,medium,no,no
|
||||||
|
high,full,none,available,unavailable,low,no,no
|
||||||
|
low,empty,available,available,available,high,no,no
|
||||||
|
low,empty,none,available,available,high,yes,no
|
||||||
|
high,full,none,available,available,medium,no,yes
|
||||||
|
empty,full,available,none,available,medium,yes,no
|
||||||
|
high,full,none,none,available,low,no,no
|
||||||
|
low,empty,available,available,unavailable,high,no,no
|
||||||
|
low,full,available,none,available,medium,yes,no
|
||||||
|
high,empty,none,none,unavailable,low,no,no
|
||||||
|
low,full,none,none,unavailable,high,yes,no
|
||||||
|
high,empty,none,available,available,low,yes,no
|
||||||
|
empty,full,available,available,unavailable,low,no,no
|
||||||
|
low,empty,available,available,unavailable,low,no,no
|
||||||
|
low,full,available,none,unavailable,low,yes,no
|
||||||
|
empty,empty,available,available,unavailable,high,no,no
|
||||||
|
medium,full,available,none,available,medium,yes,no
|
||||||
|
high,full,available,none,available,high,no,no
|
||||||
|
low,full,none,available,available,medium,yes,no
|
||||||
|
low,empty,none,available,unavailable,medium,yes,no
|
||||||
|
high,full,available,available,unavailable,medium,yes,no
|
||||||
|
high,full,none,none,unavailable,medium,yes,no
|
||||||
|
low,full,available,available,available,low,yes,no
|
||||||
|
low,full,available,available,unavailable,high,no,no
|
||||||
|
empty,full,none,none,available,medium,no,no
|
||||||
|
empty,empty,available,none,available,low,yes,no
|
||||||
|
high,full,available,none,unavailable,high,no,no
|
||||||
|
high,full,none,available,unavailable,high,no,no
|
||||||
|
low,empty,available,available,unavailable,medium,yes,no
|
||||||
|
high,empty,available,available,available,low,yes,no
|
||||||
|
empty,full,none,none,unavailable,low,no,no
|
||||||
|
high,full,none,available,unavailable,medium,yes,no
|
||||||
|
high,empty,available,none,unavailable,medium,no,no
|
||||||
|
empty,empty,available,none,available,high,yes,no
|
||||||
|
high,empty,available,none,unavailable,medium,yes,no
|
||||||
|
empty,empty,none,none,unavailable,medium,no,no
|
||||||
|
high,empty,none,available,available,high,no,no
|
||||||
|
medium,empty,none,none,unavailable,low,yes,no
|
||||||
|
medium,full,available,none,unavailable,high,no,no
|
||||||
|
high,full,none,none,unavailable,low,no,no
|
||||||
|
high,empty,none,none,unavailable,medium,no,no
|
||||||
|
medium,full,available,none,available,low,no,no
|
||||||
|
high,empty,none,none,available,high,yes,no
|
||||||
|
empty,full,available,available,available,high,no,no
|
||||||
|
medium,full,available,available,unavailable,low,no,no
|
||||||
|
empty,full,available,none,available,medium,no,no
|
||||||
|
empty,full,available,available,unavailable,medium,yes,no
|
||||||
|
empty,empty,available,none,available,high,no,no
|
||||||
|
low,empty,none,none,available,high,yes,no
|
||||||
|
empty,full,none,available,unavailable,medium,yes,no
|
||||||
|
medium,full,none,available,unavailable,medium,yes,no
|
||||||
|
medium,full,available,none,available,low,yes,no
|
||||||
|
medium,full,available,none,unavailable,high,yes,no
|
||||||
|
medium,full,available,available,available,high,no,yes
|
||||||
|
medium,full,none,none,available,low,no,no
|
||||||
|
high,full,none,available,available,high,no,yes
|
||||||
|
low,empty,available,available,unavailable,low,yes,no
|
||||||
|
low,full,none,available,unavailable,high,yes,no
|
||||||
|
medium,full,available,available,available,high,yes,no
|
||||||
|
high,full,available,available,available,low,no,no
|
||||||
|
medium,full,none,none,unavailable,high,yes,no
|
||||||
|
medium,full,none,available,unavailable,high,no,no
|
||||||
|
high,empty,none,available,unavailable,high,yes,no
|
||||||
|
empty,empty,none,available,available,medium,no,no
|
||||||
|
empty,empty,available,none,unavailable,high,no,no
|
||||||
|
high,empty,available,available,unavailable,high,yes,no
|
||||||
|
medium,empty,available,available,unavailable,low,yes,no
|
||||||
|
medium,full,none,none,unavailable,low,no,no
|
||||||
|
high,empty,none,none,available,low,no,no
|
||||||
|
high,full,available,none,unavailable,medium,no,no
|
||||||
|
high,full,available,none,unavailable,low,yes,no
|
||||||
|
empty,empty,available,available,available,low,yes,no
|
||||||
|
high,empty,none,none,unavailable,low,yes,no
|
||||||
|
medium,empty,none,none,available,low,no,no
|
||||||
|
low,full,none,available,unavailable,medium,no,no
|
||||||
|
low,full,none,available,available,high,yes,no
|
||||||
|
high,full,none,available,unavailable,high,yes,no
|
||||||
|
medium,full,none,available,available,medium,yes,no
|
||||||
|
empty,empty,none,available,unavailable,high,yes,no
|
||||||
|
medium,empty,available,none,unavailable,medium,yes,no
|
||||||
|
empty,empty,none,available,unavailable,low,yes,no
|
||||||
|
high,empty,none,available,unavailable,medium,no,no
|
||||||
|
medium,empty,available,none,available,low,yes,no
|
||||||
|
medium,full,available,available,available,medium,no,yes
|
||||||
|
high,full,available,none,unavailable,medium,yes,no
|
||||||
|
high,full,available,available,unavailable,medium,no,no
|
||||||
|
low,full,available,none,available,medium,no,no
|
||||||
|
medium,empty,available,none,unavailable,high,yes,no
|
||||||
|
medium,empty,available,none,available,medium,yes,no
|
||||||
|
high,empty,none,none,available,high,no,no
|
||||||
|
empty,full,available,none,unavailable,high,yes,no
|
||||||
|
low,empty,available,none,unavailable,low,yes,no
|
||||||
|
empty,full,available,available,available,low,yes,no
|
||||||
|
medium,empty,available,available,unavailable,medium,no,no
|
||||||
|
medium,empty,none,none,unavailable,high,no,no
|
||||||
|
medium,full,available,available,unavailable,medium,no,no
|
||||||
|
empty,full,available,available,available,medium,no,no
|
||||||
|
low,empty,available,none,available,low,no,no
|
|
200
dataset/converted_dataset.csv
Normal file
200
dataset/converted_dataset.csv
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
3,1,0,0,1,0,1,0
|
||||||
|
1,1,0,0,0,1,1,0
|
||||||
|
3,1,0,0,0,1,0,0
|
||||||
|
2,0,0,0,0,0,0,0
|
||||||
|
3,1,0,0,1,1,0,0
|
||||||
|
1,1,0,1,0,1,1,0
|
||||||
|
2,0,0,1,0,2,1,0
|
||||||
|
2,1,0,1,1,0,1,0
|
||||||
|
2,1,1,0,0,0,1,0
|
||||||
|
3,0,0,0,0,1,1,0
|
||||||
|
2,0,0,1,0,1,1,0
|
||||||
|
1,0,1,0,1,2,0,0
|
||||||
|
3,1,1,0,1,0,1,0
|
||||||
|
2,1,0,1,1,0,0,0
|
||||||
|
2,1,0,1,1,1,0,1
|
||||||
|
0,1,0,0,0,2,1,0
|
||||||
|
1,1,0,0,0,1,0,0
|
||||||
|
1,1,1,0,0,0,0,0
|
||||||
|
2,0,0,1,0,1,0,0
|
||||||
|
1,0,1,1,0,1,0,0
|
||||||
|
2,0,1,1,0,1,1,0
|
||||||
|
1,0,0,0,0,2,0,0
|
||||||
|
2,1,1,1,0,1,1,0
|
||||||
|
3,0,1,0,1,1,0,1
|
||||||
|
0,0,1,1,0,0,1,0
|
||||||
|
3,0,0,0,0,2,1,0
|
||||||
|
2,0,1,1,1,1,0,1
|
||||||
|
2,1,1,1,1,0,0,0
|
||||||
|
0,1,0,1,1,2,0,0
|
||||||
|
0,0,0,0,0,0,0,0
|
||||||
|
2,1,0,0,0,1,0,0
|
||||||
|
2,0,1,1,0,2,1,0
|
||||||
|
3,1,1,0,1,1,1,0
|
||||||
|
2,0,0,1,0,0,1,0
|
||||||
|
1,0,0,0,1,0,0,0
|
||||||
|
3,1,1,1,1,0,1,0
|
||||||
|
3,1,1,1,0,2,1,0
|
||||||
|
1,1,1,1,0,2,1,0
|
||||||
|
1,1,0,0,0,0,1,0
|
||||||
|
2,1,0,0,0,1,1,0
|
||||||
|
3,1,0,1,1,1,1,0
|
||||||
|
1,0,0,0,0,0,0,0
|
||||||
|
3,0,1,0,0,0,1,0
|
||||||
|
2,1,0,1,1,2,0,1
|
||||||
|
1,0,1,1,1,2,1,0
|
||||||
|
1,1,1,0,0,2,1,0
|
||||||
|
2,1,1,0,0,0,0,0
|
||||||
|
2,1,1,1,0,2,0,0
|
||||||
|
2,1,0,1,0,0,1,0
|
||||||
|
2,0,1,0,0,0,1,0
|
||||||
|
2,0,0,0,1,2,0,0
|
||||||
|
0,1,0,0,1,0,0,0
|
||||||
|
1,1,1,1,1,1,1,0
|
||||||
|
1,1,1,0,0,2,0,0
|
||||||
|
3,1,1,0,1,1,0,0
|
||||||
|
1,1,0,1,1,1,0,0
|
||||||
|
0,0,0,1,1,2,0,0
|
||||||
|
1,1,0,1,0,0,0,0
|
||||||
|
3,1,0,0,0,2,0,0
|
||||||
|
2,1,0,0,1,2,1,0
|
||||||
|
1,0,0,1,1,1,0,0
|
||||||
|
0,0,0,1,0,0,0,0
|
||||||
|
0,1,1,0,1,0,1,0
|
||||||
|
0,0,1,1,1,1,0,0
|
||||||
|
0,0,1,0,0,1,0,0
|
||||||
|
0,0,0,0,0,2,0,0
|
||||||
|
2,0,1,0,0,2,0,0
|
||||||
|
0,0,1,0,1,1,1,0
|
||||||
|
0,0,0,0,0,2,1,0
|
||||||
|
3,1,1,1,0,0,0,0
|
||||||
|
3,0,1,1,1,2,1,0
|
||||||
|
3,0,1,0,1,0,0,0
|
||||||
|
1,0,0,1,0,1,0,0
|
||||||
|
2,1,0,1,0,0,0,0
|
||||||
|
2,0,0,1,1,2,1,0
|
||||||
|
2,0,1,1,1,2,0,1
|
||||||
|
3,0,0,1,0,0,1,0
|
||||||
|
1,1,1,1,1,2,0,0
|
||||||
|
2,0,0,1,1,2,0,0
|
||||||
|
2,0,1,0,1,2,0,1
|
||||||
|
0,1,1,1,0,2,0,0
|
||||||
|
1,0,0,1,1,0,0,0
|
||||||
|
3,1,0,1,1,0,1,0
|
||||||
|
3,0,0,0,1,1,1,0
|
||||||
|
0,0,1,0,0,0,0,0
|
||||||
|
3,1,0,1,0,0,1,0
|
||||||
|
0,1,0,1,0,2,0,0
|
||||||
|
0,1,1,0,1,0,0,0
|
||||||
|
2,1,0,0,1,2,0,0
|
||||||
|
2,1,1,1,0,0,1,0
|
||||||
|
0,1,1,1,0,0,1,0
|
||||||
|
1,0,0,0,0,1,0,0
|
||||||
|
1,1,0,0,0,0,0,0
|
||||||
|
1,1,1,1,0,0,1,0
|
||||||
|
1,0,0,1,1,0,1,0
|
||||||
|
0,1,1,0,0,2,0,0
|
||||||
|
1,1,1,0,1,2,0,0
|
||||||
|
3,1,1,1,1,1,1,0
|
||||||
|
0,1,0,1,1,1,1,0
|
||||||
|
1,1,0,0,1,1,0,0
|
||||||
|
0,1,1,1,1,0,0,0
|
||||||
|
2,1,1,0,0,1,1,0
|
||||||
|
0,0,0,0,1,1,0,0
|
||||||
|
3,1,0,1,0,0,0,0
|
||||||
|
1,0,1,1,1,2,0,0
|
||||||
|
1,0,0,1,1,2,1,0
|
||||||
|
3,1,0,1,1,1,0,1
|
||||||
|
0,1,1,0,1,1,1,0
|
||||||
|
3,1,0,0,1,0,0,0
|
||||||
|
1,0,1,1,0,2,0,0
|
||||||
|
1,1,1,0,1,1,1,0
|
||||||
|
3,0,0,0,0,0,0,0
|
||||||
|
1,1,0,0,0,2,1,0
|
||||||
|
3,0,0,1,1,0,1,0
|
||||||
|
0,1,1,1,0,0,0,0
|
||||||
|
1,0,1,1,0,0,0,0
|
||||||
|
1,1,1,0,0,0,1,0
|
||||||
|
0,0,1,1,0,2,0,0
|
||||||
|
2,1,1,0,1,1,1,0
|
||||||
|
3,1,1,0,1,2,0,0
|
||||||
|
1,1,0,1,1,1,1,0
|
||||||
|
1,0,0,1,0,1,1,0
|
||||||
|
3,1,1,1,0,1,1,0
|
||||||
|
3,1,0,0,0,1,1,0
|
||||||
|
1,1,1,1,1,0,1,0
|
||||||
|
1,1,1,1,0,2,0,0
|
||||||
|
0,1,0,0,1,1,0,0
|
||||||
|
0,0,1,0,1,0,1,0
|
||||||
|
3,1,1,0,0,2,0,0
|
||||||
|
3,1,0,1,0,2,0,0
|
||||||
|
1,0,1,1,0,1,1,0
|
||||||
|
3,0,1,1,1,0,1,0
|
||||||
|
0,1,0,0,0,0,0,0
|
||||||
|
3,1,0,1,0,1,1,0
|
||||||
|
3,0,1,0,0,1,0,0
|
||||||
|
0,0,1,0,1,2,1,0
|
||||||
|
3,0,1,0,0,1,1,0
|
||||||
|
0,0,0,0,0,1,0,0
|
||||||
|
3,0,0,1,1,2,0,0
|
||||||
|
2,0,0,0,0,0,1,0
|
||||||
|
2,1,1,0,0,2,0,0
|
||||||
|
3,1,0,0,0,0,0,0
|
||||||
|
3,0,0,0,0,1,0,0
|
||||||
|
2,1,1,0,1,0,0,0
|
||||||
|
3,0,0,0,1,2,1,0
|
||||||
|
0,1,1,1,1,2,0,0
|
||||||
|
2,1,1,1,0,0,0,0
|
||||||
|
0,1,1,0,1,1,0,0
|
||||||
|
0,1,1,1,0,1,1,0
|
||||||
|
0,0,1,0,1,2,0,0
|
||||||
|
1,0,0,0,1,2,1,0
|
||||||
|
0,1,0,1,0,1,1,0
|
||||||
|
2,1,0,1,0,1,1,0
|
||||||
|
2,1,1,0,1,0,1,0
|
||||||
|
2,1,1,0,0,2,1,0
|
||||||
|
2,1,1,1,1,2,0,1
|
||||||
|
2,1,0,0,1,0,0,0
|
||||||
|
3,1,0,1,1,2,0,1
|
||||||
|
1,0,1,1,0,0,1,0
|
||||||
|
1,1,0,1,0,2,1,0
|
||||||
|
2,1,1,1,1,2,1,0
|
||||||
|
3,1,1,1,1,0,0,0
|
||||||
|
2,1,0,0,0,2,1,0
|
||||||
|
2,1,0,1,0,2,0,0
|
||||||
|
3,0,0,1,0,2,1,0
|
||||||
|
0,0,0,1,1,1,0,0
|
||||||
|
0,0,1,0,0,2,0,0
|
||||||
|
3,0,1,1,0,2,1,0
|
||||||
|
2,0,1,1,0,0,1,0
|
||||||
|
2,1,0,0,0,0,0,0
|
||||||
|
3,0,0,0,1,0,0,0
|
||||||
|
3,1,1,0,0,1,0,0
|
||||||
|
3,1,1,0,0,0,1,0
|
||||||
|
0,0,1,1,1,0,1,0
|
||||||
|
3,0,0,0,0,0,1,0
|
||||||
|
2,0,0,0,1,0,0,0
|
||||||
|
1,1,0,1,0,1,0,0
|
||||||
|
1,1,0,1,1,2,1,0
|
||||||
|
3,1,0,1,0,2,1,0
|
||||||
|
2,1,0,1,1,1,1,0
|
||||||
|
0,0,0,1,0,2,1,0
|
||||||
|
2,0,1,0,0,1,1,0
|
||||||
|
0,0,0,1,0,0,1,0
|
||||||
|
3,0,0,1,0,1,0,0
|
||||||
|
2,0,1,0,1,0,1,0
|
||||||
|
2,1,1,1,1,1,0,1
|
||||||
|
3,1,1,0,0,1,1,0
|
||||||
|
3,1,1,1,0,1,0,0
|
||||||
|
1,1,1,0,1,1,0,0
|
||||||
|
2,0,1,0,0,2,1,0
|
||||||
|
2,0,1,0,1,1,1,0
|
||||||
|
3,0,0,0,1,2,0,0
|
||||||
|
0,1,1,0,0,2,1,0
|
||||||
|
1,0,1,0,0,0,1,0
|
||||||
|
0,1,1,1,1,0,1,0
|
||||||
|
2,0,1,1,0,1,0,0
|
||||||
|
2,0,0,0,0,2,0,0
|
||||||
|
2,1,1,1,0,1,0,0
|
||||||
|
0,1,1,1,1,1,0,0
|
||||||
|
1,0,1,0,1,0,0,0
|
|
54
dataset/datasetConverter.py
Normal file
54
dataset/datasetConverter.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import csv
|
||||||
|
|
||||||
|
def convert_dataset(input_file, output_file):
|
||||||
|
attributes = {
|
||||||
|
1: ["empty", "low", "medium", "high"],
|
||||||
|
2: ["empty", "full"],
|
||||||
|
3: ["none", "available"],
|
||||||
|
4: ["none", "available"],
|
||||||
|
5: ["unavailable", "available"],
|
||||||
|
6: ["low", "medium", "high"],
|
||||||
|
7: ["no", "yes"],
|
||||||
|
8: ["no", "yes"]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a mapping dictionary for attribute values
|
||||||
|
mapping = {}
|
||||||
|
for attr, values in attributes.items():
|
||||||
|
mapping[attr] = {value: index for index, value in enumerate(values)}
|
||||||
|
|
||||||
|
converted_dataset = []
|
||||||
|
|
||||||
|
# Read the input CSV file
|
||||||
|
with open(input_file, "r") as csvfile:
|
||||||
|
reader = csv.reader(csvfile)
|
||||||
|
|
||||||
|
header = next(reader) # Skip the header row
|
||||||
|
|
||||||
|
# Convert the data rows
|
||||||
|
for row in reader:
|
||||||
|
converted_row = []
|
||||||
|
for i, value in enumerate(row):
|
||||||
|
# Convert the attribute values
|
||||||
|
if i + 1 in mapping:
|
||||||
|
converted_value = mapping[i + 1][value]
|
||||||
|
else:
|
||||||
|
converted_value = value
|
||||||
|
|
||||||
|
converted_row.append(converted_value)
|
||||||
|
|
||||||
|
converted_dataset.append(converted_row)
|
||||||
|
|
||||||
|
# Write the converted dataset to a new CSV file
|
||||||
|
with open(output_file, "w", newline="") as csvfile:
|
||||||
|
writer = csv.writer(csvfile)
|
||||||
|
|
||||||
|
# Write the header row
|
||||||
|
#writer.writerow(header)
|
||||||
|
|
||||||
|
# Write the converted data rows
|
||||||
|
for row in converted_dataset:
|
||||||
|
writer.writerow(row)
|
||||||
|
|
||||||
|
# Example usage:
|
||||||
|
convert_dataset("dataset/Dataset.csv", "dataset/converted_dataset.csv")
|
57
dataset/datasetGenerator.py
Normal file
57
dataset/datasetGenerator.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import random
|
||||||
|
import csv
|
||||||
|
|
||||||
|
attributes = {
|
||||||
|
1: ["empty", "low", "medium", "high"],
|
||||||
|
2: ["empty", "full"],
|
||||||
|
3: ["none", "available"],
|
||||||
|
4: ["none", "available"],
|
||||||
|
5: ["unavailable", "available"],
|
||||||
|
6: ["low", "medium", "high"],
|
||||||
|
7: ["no", "yes"],
|
||||||
|
8: ["no", "yes"]
|
||||||
|
}
|
||||||
|
|
||||||
|
dataset = []
|
||||||
|
while len(dataset) < 200:
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
# Generate random values for attributes 1-7
|
||||||
|
for attr in range(1, 8):
|
||||||
|
data[attr] = random.choice(attributes[attr])
|
||||||
|
|
||||||
|
# Apply the rules to determine the value of attribute 8
|
||||||
|
if data[1] in ["empty", "low"]:
|
||||||
|
data[8] = "no"
|
||||||
|
elif data[2] == "full" and data[4] == "none":
|
||||||
|
data[8] = "no"
|
||||||
|
elif data[2] == "empty" and data[3] == "none":
|
||||||
|
data[8] = "no"
|
||||||
|
elif data[3] == "none" and data[4] == "none":
|
||||||
|
data[8] = "no"
|
||||||
|
elif data[5] == "unavailable":
|
||||||
|
data[8] = "no"
|
||||||
|
elif data[6] == "low":
|
||||||
|
data[8] = "no"
|
||||||
|
elif data[7] == "yes":
|
||||||
|
data[8] = "no"
|
||||||
|
else:
|
||||||
|
data[8] = "yes"
|
||||||
|
|
||||||
|
# Check if the generated data already exists in the dataset
|
||||||
|
if data not in dataset:
|
||||||
|
dataset.append(data)
|
||||||
|
|
||||||
|
# Print the generated dataset
|
||||||
|
for data in dataset:
|
||||||
|
print(data)
|
||||||
|
with open("dataset/Dataset.csv", "w", newline="") as csvfile:
|
||||||
|
writer = csv.writer(csvfile)
|
||||||
|
|
||||||
|
# Write the header row
|
||||||
|
writer.writerow(["Battery Charge", "Fullness", "Ready orders", "Waiting tables","Availability", "Cleanliness", "Error", "To go"])
|
||||||
|
|
||||||
|
# Write the data rows
|
||||||
|
for data in dataset:
|
||||||
|
row = [data[attr] for attr in range(1, 9)]
|
||||||
|
writer.writerow(row)
|
@ -6,6 +6,12 @@ class Waiter(Object):
|
|||||||
def __init__(self, position, orientation, square_size, screen_size, basket=[]):
|
def __init__(self, position, orientation, square_size, screen_size, basket=[]):
|
||||||
super().__init__("waiter", position, orientation, square_size, screen_size)
|
super().__init__("waiter", position, orientation, square_size, screen_size)
|
||||||
self.basket_size = 2
|
self.basket_size = 2
|
||||||
|
self.battery=2
|
||||||
|
self.orderReadiness=1
|
||||||
|
self.waitingTables=1
|
||||||
|
self.availability=1
|
||||||
|
self.cleanliness=2
|
||||||
|
self.error=1
|
||||||
self.basket = basket
|
self.basket = basket
|
||||||
self.prev_position = copy.deepcopy(self.position)
|
self.prev_position = copy.deepcopy(self.position)
|
||||||
self.prev_orientation = copy.copy(self.orientation)
|
self.prev_orientation = copy.copy(self.orientation)
|
||||||
@ -14,8 +20,78 @@ class Waiter(Object):
|
|||||||
self.position = copy.deepcopy(state.position)
|
self.position = copy.deepcopy(state.position)
|
||||||
self.orientation = copy.copy(state.orientation)
|
self.orientation = copy.copy(state.orientation)
|
||||||
self.basket = copy.copy(state.basket)
|
self.basket = copy.copy(state.basket)
|
||||||
|
self.calcTree()
|
||||||
return state
|
return state
|
||||||
|
|
||||||
|
def calcTree(self):
|
||||||
|
from sklearn import tree
|
||||||
|
import pandas as pd #for manipulating the csv data
|
||||||
|
import numpy as np
|
||||||
|
import os
|
||||||
|
|
||||||
|
train_data_m=np.genfromtxt("dataset/converted_dataset.csv", delimiter=",",skip_header=1); #importing the dataset from the disk
|
||||||
|
|
||||||
|
|
||||||
|
X_train = [data[:-1] for data in train_data_m]
|
||||||
|
y_train = [data[-1] for data in train_data_m]
|
||||||
|
# Create the decision tree classifier using the ID3 algorithm
|
||||||
|
clf = tree.DecisionTreeClassifier(criterion='entropy')
|
||||||
|
|
||||||
|
# Train the decision tree on the training data
|
||||||
|
clf.fit(X_train, y_train)
|
||||||
|
|
||||||
|
# Visualize the trained decision tree
|
||||||
|
tree_text = tree.export_text(clf,feature_names=['Battery Charge', 'Fullness', 'Ready orders', 'Waiting tables','Availability', 'Cleanliness', 'Error'])
|
||||||
|
with open('decision_tree.txt', 'w') as f:
|
||||||
|
f.write(tree_text) # Save the visualization as a text file
|
||||||
|
|
||||||
|
# Test the decision tree with a new example
|
||||||
|
#Battery Charge,Fullness,Ready orders,Waiting tables,Availability,Cleanliness,Error
|
||||||
|
new_example = [self.battery, 0,self.orderReadiness,self.waitingTables,self.availability, self.cleanliness, self.error]
|
||||||
|
predicted_label = clf.predict([new_example])
|
||||||
|
if predicted_label[0]>0:
|
||||||
|
result="YES"
|
||||||
|
else:
|
||||||
|
result="NO"
|
||||||
|
print("Predicted Label:", result)
|
||||||
|
|
||||||
|
def calcTreePDF(self):
|
||||||
|
from sklearn import tree
|
||||||
|
import pandas as pd #for manipulating the csv data
|
||||||
|
import numpy as np
|
||||||
|
import graphviz
|
||||||
|
import os
|
||||||
|
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz/bin/'
|
||||||
|
|
||||||
|
train_data_m=np.genfromtxt("dataset/converted_dataset.csv", delimiter=",",skip_header=1); #importing the dataset from the disk
|
||||||
|
|
||||||
|
|
||||||
|
X_train = [data[:-1] for data in train_data_m]
|
||||||
|
y_train = [data[-1] for data in train_data_m]
|
||||||
|
# Create the decision tree classifier using the ID3 algorithm
|
||||||
|
clf = tree.DecisionTreeClassifier(criterion='entropy')
|
||||||
|
|
||||||
|
# Train the decision tree on the training data
|
||||||
|
clf.fit(X_train, y_train)
|
||||||
|
|
||||||
|
# Visualize the trained decision tree
|
||||||
|
tree_text = tree.export_text(clf,feature_names=['Battery Charge', 'Fullness', 'Ready orders', 'Waiting tables','Availability', 'Cleanliness', 'Error'])
|
||||||
|
with open('decision_tree.txt', 'w') as f:
|
||||||
|
f.write(tree_text) # Save the visualization as a text file
|
||||||
|
dot_data = tree.export_graphviz(clf, out_file=None, feature_names=['Battery Charge', 'Fullness', 'Ready orders', 'Waiting tables','Availability', 'Cleanliness', 'Error'], class_names=['NO', 'YES'], filled=True,rounded=True)
|
||||||
|
graph = graphviz.Source(dot_data)
|
||||||
|
graph.render("decision_tree") # Save the visualization as a PDF file
|
||||||
|
|
||||||
|
# Test the decision tree with a new example
|
||||||
|
#Battery Charge,Fullness,Ready orders,Waiting tables,Availability,Cleanliness,Error
|
||||||
|
new_example = [self.battery, 0,self.orderReadiness,self.waitingTables,self.availability, self.cleanliness, self.error]
|
||||||
|
predicted_label = clf.predict([new_example])
|
||||||
|
if predicted_label[0]>0:
|
||||||
|
result="YES"
|
||||||
|
else:
|
||||||
|
result="NO"
|
||||||
|
print("Predicted Label:", result)
|
||||||
|
|
||||||
def dampState(self):
|
def dampState(self):
|
||||||
self.prev_position = copy.deepcopy(self.position)
|
self.prev_position = copy.deepcopy(self.position)
|
||||||
self.prev_orientation = copy.copy(self.orientation)
|
self.prev_orientation = copy.copy(self.orientation)
|
||||||
|
Loading…
Reference in New Issue
Block a user