ift7025-projet/Code/main.py
2019-05-02 03:03:22 -04:00

70 lines
2.5 KiB
Python

# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import sys
import load_datasets as ld
import NeuralNet # importer la classe du Réseau de Neurones
import DecisionTree # importer la classe de l'Arbre de Décision
import NeuralNetUtils as nnu
# importer d'autres fichiers et classes si vous en avez développés
# importer d'autres bibliothèques au besoin, sauf celles qui font du machine learning
train1, train_labels1, test1, test_labels1 = ld.load_iris_dataset(train_ratio = 0.7)
train2, train_labels2, test2, test_labels2 = ld.load_monks_dataset(1)
train3, train_labels3, test3, test_labels3 = ld.load_monks_dataset(2)
train4, train_labels4, test4, test_labels4 = ld.load_monks_dataset(3)
train5, train_labels5, test5, test_labels5 = ld.load_congressional_dataset(train_ratio = 0.7)
dt1 = DecisionTree.DecisionTree(attribute_type="continuous")
dt1.train(train1, train_labels1)
dt1.predict(test1[0],test_labels1[0])
dt1.test(test1, test_labels1)
dt2 = DecisionTree.DecisionTree(attribute_type="discrete")
dt2.train(train2, train_labels2)
dt2.tree
dt2.predict(test2[0],test_labels2[0])
dt2.test(test2, test_labels2)
dt3 = DecisionTree.DecisionTree(attribute_type="discrete")
dt3.train(train3, train_labels3)
dt3.tree
dt3.predict(test3[0],test_labels3[0])
dt3.test(test3, test_labels3)
dt4 = DecisionTree.DecisionTree(attribute_type="discrete")
dt4.train(train4, train_labels4)
dt4.tree
dt4.predict(test4[0],test_labels4[0])
dt4.test(test4, test_labels4)
dt5 = DecisionTree.DecisionTree(attribute_type="discrete")
dt5.train(train5, train_labels5)
dt5.predict(test5[0],test_labels5[0])
dt5.test(test5, test_labels5)
nn1 = NeuralNet.NeuralNet(np.array([4,8,3]),range(3))
nn1.train(train1, train_labels1, 0.1, 10)
nn1.predict(test1[0],test_labels1[0])
nn1.test(test1,test_labels1)
nn2 = NeuralNet.NeuralNet(np.array([6,12,2]),range(2))
nn2.train(train2, train_labels2, 0.1, 10)
nn2.predict(test2[0],test_labels2[0])
nn2.test(test2,test_labels2)
nn3 = NeuralNet.NeuralNet(np.array([6,12,2]),range(2))
nn3.train(train3, train_labels3, 0.1, 10)
nn3.predict(test3[0],test_labels3[0])
nn3.test(test3,test_labels3)
nn4 = NeuralNet.NeuralNet(np.array([6,12,2]),range(2))
nn4.train(train4, train_labels4, 0.1, 10)
nn4.predict(test4[0],test_labels4[0])
nn4.test(test4,test_labels4)
nn5 = NeuralNet.NeuralNet(np.array([16,128,3]),range(3))
nn5.train(train5, train_labels5, 0.1, 10)
nn5.predict(test5[0],test_labels5[0])
nn5.test(test5,test_labels5)