sztuczna_inteligencja_2023_.../machine_learning/decisionTree.py
2023-05-27 11:34:26 +02:00

23 lines
719 B
Python

import os
from trainingData import TrainingData
def _read_training_data() -> TrainingData:
attributes: list[list[str]] = []
classes: list[str] = []
__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))
file = open(os.path.join(__location__, 'training_data.csv'))
lines = file.readlines()[1:]
file.close()
for line in lines:
actual_row = line.replace('\n', '')
values = actual_row.split(',')
line_attributes = values[:-1]
line_class = values[-1]
attributes.append(line_attributes)
classes.append(line_class)
return TrainingData(attributes, classes)
trainning_data = _read_training_data()