2019-04-29 05:10:20 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import numpy as np
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
import sys
|
2019-05-02 06:49:42 +00:00
|
|
|
import load_datasets as ld
|
2019-04-29 05:10:20 +00:00
|
|
|
import NeuralNet # importer la classe du Réseau de Neurones
|
|
|
|
import DecisionTree # importer la classe de l'Arbre de Décision
|
2019-05-02 06:49:42 +00:00
|
|
|
import NeuralNetUtils as nnu
|
2019-04-29 05:10:20 +00:00
|
|
|
# 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
|
|
|
|
|
2019-04-30 01:35:45 +00:00
|
|
|
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)
|
2019-04-29 05:10:20 +00:00
|
|
|
|
|
|
|
|
2019-04-30 01:35:45 +00:00
|
|
|
dt1 = DecisionTree.DecisionTree(attribute_type="continuous")
|
|
|
|
dt1.train(train1, train_labels1)
|
|
|
|
dt1.predict(test1[0],test_labels1[0])
|
|
|
|
dt1.test(test1, test_labels1)
|
2019-04-30 00:20:05 +00:00
|
|
|
|
2019-04-30 02:28:32 +00:00
|
|
|
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)
|
2019-04-30 01:35:45 +00:00
|
|
|
|
|
|
|
dt5 = DecisionTree.DecisionTree(attribute_type="discrete")
|
|
|
|
dt5.train(train5, train_labels5)
|
|
|
|
dt5.predict(test5[0],test_labels5[0])
|
2019-05-01 03:31:50 +00:00
|
|
|
dt5.test(test5, test_labels5)
|
|
|
|
|
2019-05-03 02:25:24 +00:00
|
|
|
nn1 = NeuralNet.NeuralNet(np.array([4,4,3]),range(3))
|
2019-05-02 07:03:22 +00:00
|
|
|
nn1.train(train1, train_labels1, 0.1, 10)
|
2019-05-02 06:49:42 +00:00
|
|
|
nn1.predict(test1[0],test_labels1[0])
|
|
|
|
nn1.test(test1,test_labels1)
|
2019-05-02 07:03:22 +00:00
|
|
|
|
|
|
|
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)
|