Skip to content

Commit

Permalink
starting DecisionTreeAG
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascarvalhoroncoroni committed Aug 29, 2017
1 parent 5bffa36 commit 5e19b4a
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
Binary file not shown.
37 changes: 37 additions & 0 deletions mainproject/SFAnalytics/generatedgrah.gv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
digraph Tree {
node [shape=box, style="filled, rounded", color="black", fontname=helvetica] ;
edge [fontname=helvetica] ;
0 [label=<petal length (cm) &le; 2.45<br/>gini = 0.6667<br/>samples = 150<br/>value = [50, 50, 50]<br/>class = setosa>, fillcolor="#e5813900"] ;
1 [label=<gini = 0.0<br/>samples = 50<br/>value = [50, 0, 0]<br/>class = setosa>, fillcolor="#e58139ff"] ;
0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;
2 [label=<petal width (cm) &le; 1.75<br/>gini = 0.5<br/>samples = 100<br/>value = [0, 50, 50]<br/>class = versicolor>, fillcolor="#39e58100"] ;
0 -> 2 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;
3 [label=<petal length (cm) &le; 4.95<br/>gini = 0.168<br/>samples = 54<br/>value = [0, 49, 5]<br/>class = versicolor>, fillcolor="#39e581e5"] ;
2 -> 3 ;
4 [label=<petal width (cm) &le; 1.65<br/>gini = 0.0408<br/>samples = 48<br/>value = [0, 47, 1]<br/>class = versicolor>, fillcolor="#39e581fa"] ;
3 -> 4 ;
5 [label=<gini = 0.0<br/>samples = 47<br/>value = [0, 47, 0]<br/>class = versicolor>, fillcolor="#39e581ff"] ;
4 -> 5 ;
6 [label=<gini = 0.0<br/>samples = 1<br/>value = [0, 0, 1]<br/>class = virginica>, fillcolor="#8139e5ff"] ;
4 -> 6 ;
7 [label=<petal width (cm) &le; 1.55<br/>gini = 0.4444<br/>samples = 6<br/>value = [0, 2, 4]<br/>class = virginica>, fillcolor="#8139e57f"] ;
3 -> 7 ;
8 [label=<gini = 0.0<br/>samples = 3<br/>value = [0, 0, 3]<br/>class = virginica>, fillcolor="#8139e5ff"] ;
7 -> 8 ;
9 [label=<petal length (cm) &le; 5.45<br/>gini = 0.4444<br/>samples = 3<br/>value = [0, 2, 1]<br/>class = versicolor>, fillcolor="#39e5817f"] ;
7 -> 9 ;
10 [label=<gini = 0.0<br/>samples = 2<br/>value = [0, 2, 0]<br/>class = versicolor>, fillcolor="#39e581ff"] ;
9 -> 10 ;
11 [label=<gini = 0.0<br/>samples = 1<br/>value = [0, 0, 1]<br/>class = virginica>, fillcolor="#8139e5ff"] ;
9 -> 11 ;
12 [label=<petal length (cm) &le; 4.85<br/>gini = 0.0425<br/>samples = 46<br/>value = [0, 1, 45]<br/>class = virginica>, fillcolor="#8139e5f9"] ;
2 -> 12 ;
13 [label=<sepal length (cm) &le; 5.95<br/>gini = 0.4444<br/>samples = 3<br/>value = [0, 1, 2]<br/>class = virginica>, fillcolor="#8139e57f"] ;
12 -> 13 ;
14 [label=<gini = 0.0<br/>samples = 1<br/>value = [0, 1, 0]<br/>class = versicolor>, fillcolor="#39e581ff"] ;
13 -> 14 ;
15 [label=<gini = 0.0<br/>samples = 2<br/>value = [0, 0, 2]<br/>class = virginica>, fillcolor="#8139e5ff"] ;
13 -> 15 ;
16 [label=<gini = 0.0<br/>samples = 43<br/>value = [0, 0, 43]<br/>class = virginica>, fillcolor="#8139e5ff"] ;
12 -> 16 ;
}
44 changes: 44 additions & 0 deletions mainproject/SFAnalytics/migrations/0007_auto_20170829_1215.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-08-29 15:15
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('SFAnalytics', '0006_auto_20170613_1934'),
]

operations = [
migrations.CreateModel(
name='DllToEntry',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id_dll', models.IntegerField(default=0)),
('id_entry', models.IntegerField(default=0)),
],
),
migrations.CreateModel(
name='OpcodeToEntry',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id_opcode', models.IntegerField(default=0)),
('id_entry', models.IntegerField(default=0)),
],
),
migrations.CreateModel(
name='StringToEntry',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('id_string', models.IntegerField(default=0)),
('id_entry', models.IntegerField(default=0)),
],
),
migrations.AlterField(
model_name='entryfile',
name='id',
field=models.IntegerField(primary_key=True, serialize=False),
),
]
26 changes: 26 additions & 0 deletions mainproject/SFAnalytics/test_mining.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from tools import *
from sklearn.datasets import load_iris
from sklearn import tree
import sys
import numpy as np
import graphviz

def main():
#The secound arg is the outputfile
if len(sys.argv) == 2:
iris = load_iris()
decisionTree = tree.DecisionTreeClassifier()
decisionTree = decisionTree.fit(iris.data, iris.target)
sample = np.reshape(iris.data[50], (1, -1))
dot_data = tree.export_graphviz(decisionTree, out_file=None, feature_names=iris.feature_names, class_names=iris.target_names, filled=True, rounded=True, special_characters=True)
graph = graphviz.Source(dot_data)
graph.format = 'png'
graph.render(sys.argv[1])
print('\nGraph generated.\n')
a = np.array([[2, 3, 4],[5, 6, 7],[8, 9, 10]])
b = np.array([[11, 12, 13]])
#stacking arrays
np.vstack((a, b))

if __name__ == '__main__':
main()

0 comments on commit 5e19b4a

Please sign in to comment.