예제 #1
0
from data_preparing.cleaner import handle_missing_values
from tools.io_handlers import read, write, read_classes

task = 'hepatitis'

samples, names = read(task)
classes = read_classes(task)
c_samples, c_names = handle_missing_values(samples, names, "average", -1, -1)

for c_sample in c_samples:
    if c_sample.classification in [1.0, 2.0]:
        c_sample.classification -= 1
    else:
        raise Exception('Wrong encoding of classes.')

c_names_lines = [x + '\n' for x in c_names]
c_data_lines = [str(int(s.classification)) + ',' + ','.join(s.attributes) + '\n' for s in c_samples]
write(task, c_names_lines, c_data_lines, 'c')
예제 #2
0
from model.ai import loo_train_test_iteration
from model.configs import AnnConfig
from tools.io_handlers import read

"""Trzeci dostrajany parametr"""

data_folder = 'hepatitis'
results = []

samples, names = read(data_folder, file_type='b')
layers = [256, 192, 128, 64, 64, 64, 64, 64]
features = len(names)
epochs = [10, 50, 100, 500, 1000, 10000]
batch_size = len(samples) - 1

for i in range(len(epochs)):
    config = AnnConfig(layers, features, epochs[i], batch_size, data_folder)
    results.append(loo_train_test_iteration(config, samples, use_tree=False))

file = open("My mcc dependency of epochs", "w+")
for i in range(len(epochs)):
    file.write(str(epochs[i]) + ' : ' + str(results[i]) + '\n')
file.close()
from data_preparing.cleaner import balance_data, normalize_data
from tools.io_handlers import read, write

task = 'hepatitis'

samples, names = read(task, 'c')

samples = balance_data(samples)
normalize_data(samples)

b_names_lines = [x + '\n' for x in names]
b_data_lines = [str(int(s.classification)) + ',' + ','.join([str(a) for a in s.attributes]) + '\n' for s in samples]
write(task, b_names_lines, b_data_lines, 'b')