def train_ignore_features():
    data_limit = 10
    model_name = 'first_linear_then_more_GraphConvs_then_linear'
    predict_type = 'y_combine_all_percent'

    train_d, train_f, val_d, val_f, word_to_ixs = data(data_limit)
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    print('Number of features', NODE_FEATURES_NUM)
    x_list = list(range(NODE_FEATURES_NUM))
    auc_list = []

    for i in x_list:
        my_models = MyModels(word_to_ixs, ignore_columns=[i])
        net = my_models.my_models[model_name]
        criterion = nn.CrossEntropyLoss(
            weight=torch.tensor([1.0, 6.0], device=device))
        training_h, validation_h, whole_training_h = run(net,
                                                         train_d,
                                                         val_d,
                                                         device=device,
                                                         criterion=criterion,
                                                         batch_size=10,
                                                         epochs=2,
                                                         model_name=model_name,
                                                         save=False)
        thresholds, aucs = calculate_metrics(val_d,
                                             net,
                                             print_model_name=None,
                                             do_plot=False,
                                             save=False)
        auc_list.append(aucs[predict_type])

    plt.figure()
    plt.bar(x_list, auc_list)
    plt.show()
import main as mn
import sqlite3 as sql

con = sql.connect("Pyth")

usr = input("Username: "******"Password: "******"insert into data values ('" + usr + "','" + x["hash"] + "','" +
            str(x["num"]) + "')")
con.commit()
Exemple #3
0
import altair as alt
import main
import pandas as pd

source = main.data()

chart = alt.Chart(source).mark_bar().encode(x='id', y="loc")
# The highlight will be set on the result of a conditional statement

chart_1 = alt.Chart(source).mark_circle(size=60).encode(
    x='id',
    y='CC',
    color='file_name',
    #tooltip=['Origin', 'Horsepower', 'Miles_per_Gallon']
).interactive()

chart_2 = alt.Chart(source).mark_line().encode(x='id', y='CC')

chart.save('chart.html')
Exemple #4
0
false_pos = []
right = []
A = 1
B = 1
C = 1
D = 1
E = 1
correct_attempts = 0
THRESHOLD = 500

with open("data.txt", "r") as f:
    for line in f.readlines():
        pos = line.find(":")
        userdata = ""
        exec("userdata = " + line[pos + 1:-1])
        todo.append([line[0:pos], main.data(userdata)])

while percentage < 70 or not false_pos:
    wrong = []
    right = []
    false_pos = []
    correct_attempts = 0
    for item in todo:
        score = user.checkTest(item[1], A, B, C, D, E)
        if (score >= THRESHOLD and item[0] == "joe"):
            correct_attempts += 1
            wrong.append(item)
        elif (score < THRESHOLD and item[0] != "joe"):
            false_pos.append(item)
            wrong.append(item)
        else:
Exemple #5
0
import numpy as np
import main, pickle

#load the data from the main script
norm = main.data()[0]
test_data = main.data()[3]
test_labels = main.data()[4]
total = main.data()[6]
hot_label = main.data()[7]

#load the parameters from the main script
net = main.network()[0]


#activation function
def f(z):
    if z > 100.0:
        return 1.0
    elif z < -100.0:
        return 0.0
    else:
        return 1.0 / (1.0 + np.exp(-z))


x = []  #input to each neuron
y = []  #activation of each neuron
for layer in range(len(net)):
    x.append(np.array([0.0] * net[layer]))
    y.append(np.array([0.0] * net[layer]))

Exemple #6
0
import random, sys, pickle
import numpy as np
import main, test

#load the data from the main script
norm = main.data()[0]
training_data = main.data()[1]
training_labels = main.data()[2]
check_test = main.data()[5]
hot_label = main.data()[7]

#load the parameters from the main script
net = main.network()[0]
epochs = main.network()[1]
number_examples = main.network()[2]
mini_batch_size = main.network()[3]
suffle_training = main.network()[4]
learning_rate = main.network()[5]
momentum_rate = main.network()[6]
tau = main.network()[7]
period = main.network()[8]


#activation function
def f(z):
    if z > 100.0:
        return 1.0
    elif z < -100.0:
        return 0.0
    else:
        return 1.0 / (1.0 + np.exp(-z))