ift7025-projet/Code/main.py

51 lines
1.8 KiB
Python
Raw Normal View History

2019-04-29 05:10:20 +00:00
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import sys
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
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 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])
dt5.test(test5, test_labels5)
nn1 = NeuralNet.NeuralNet(np.array([4,4,3]),range(3))
nn1.train(train1, train_labels1, 0.1, 100)
nn1.predict(test1[0],test_labels1[0])
nn1.test(test1,test_labels1)