From f9f774ba51a5a2d22a2c92337044ac14231dd0ee Mon Sep 17 00:00:00 2001 From: Paulina J Date: Mon, 10 Jun 2019 11:26:22 +0200 Subject: [PATCH] poprawny porogram --- Tree1.py | 22 ++++++++++------------ dane.txt | 2 -- tractor.py | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Tree1.py b/Tree1.py index 02f7219..efea8c5 100644 --- a/Tree1.py +++ b/Tree1.py @@ -26,19 +26,17 @@ class TreeClass: #print(com) def make_tree(self, plant, pl_stats): - features = [] + features = [] + + with open('dane.txt') as data: + for line in data: + elements = line.split(", ") + if elements[1] == "True": + elements[1] = 1 + if elements[1] == "False": + elements[1] = 0 - with open('dane.txt') as data: - for line in data: - elements = line.split(", ") - for element in elements: - if element == "True": - element = True - elif element == "False": - element = False - else: - element = int(element) - features.append(elements) + features.append(elements) labels = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, diff --git a/dane.txt b/dane.txt index f2953ed..a9e608b 100644 --- a/dane.txt +++ b/dane.txt @@ -273,5 +273,3 @@ 0, False, 230, 850, 180 0, False, 2345, 21, 342 0, False, 2561, 244, 532 - - diff --git a/tractor.py b/tractor.py index a4d3a4a..631c31d 100755 --- a/tractor.py +++ b/tractor.py @@ -5,7 +5,7 @@ from Graph import Graph from Cucumber import Cucumber from Tomato import Tomato from sklearn import tree -from Tree import TreeClass +from Tree1 import TreeClass class Tractor(TreeClass):