import json
import random

import numpy as np

from src.utils2 import c_ex as c, get_path
import src.dataloaders as d
from src.logistic import fit_logistic_regression


path = get_path(__file__) + '/..'

D = d.trainingset_extended()
Dt = d.testset_extended()

cols = c('sde5', 'v11', 'e9')

a = range(D.shape[0])
random.shuffle(a)

X = D[:, cols]
X = X[a[:320000], :]
y = D[a[:320000], c('isalert')]
y = y.astype(int)^1

Xt = D[:, cols]
Xt = Xt[a[320000:], :]
yt = D[a[320000:], c('isalert')]
yt = yt.astype(int)^1

num_tests = 1
Beispiel #2
0
learningrate = 0.04
max_epochs = 40
continue_epochs = 6
training_size = 100000
feature_set = 'forward'

if feature_set == 'winner':
    features = ['sde5', 'v11', 'e9']
elif feature_set == 'forward':
    features = ['sde1', 'v11', 'e9']
else:
    raise Exception('Unknown feature set')


if training_size == 'all':
    D = d.trainingset_extended()
    training_size = int(D.shape[0])
else:
    D = get_random_subset(d.trainingset_extended(), training_size)
T = d.testset_extended()

cols = c(*features)

Xt = T[:, cols]
yt = T[:, c.isalert]


bins = get_bins(T.shape[0], num_bins)

neural_network = train_network(D[:, cols], D[:, c.isalert], 
        hidden_units=hidden_units, learningrate=learningrate,