예제 #1
0
 def __init__(self):
     train_data, train_label, test_data, test_label = read_data(2)
     train_data.astype('float16')
     train_data = train_data / 255
     test_data.astype('float16')
     test_data = test_data / 255
     self.train_data = dataset(train_data)
     self.train_label = dataset(self.modify_label(train_label))
     self.test_data = dataset(test_data)
     self.test_label = dataset(self.modify_label(test_label))
예제 #2
0
def main():
    train_data, train_label, test_data, test_label = read_data("HOG")
    #load_predict("mlp3", test_data, test_label)
    print("Fitting...")
    clf = SVM(train_data, train_label)
    save_model(clf, "svm7")
    print("Predicting...")
    #pca = PCA(n_components=100)
    #test_data = pca.fit_transform(test_data)
    #test_data = test_data[:300]
    #test_label = test_label[:300]
    predict_label = clf.predict(test_data)
    #predict_label = m3(test_data)
    acc = accuracy(test_label, predict_label)
    print("Accuracy: ", acc)
예제 #3
0
파일: predict.py 프로젝트: mu853/aiclub
import numpy as np
import sys
import chainer
from chainer import Variable, serializers
from prepare import get_typemap, read_data
from model import create_model2

inputdata_file = sys.argv[1]
model_file_name = sys.argv[2]
state_file_name = sys.argv[3]

typemap = get_typemap(inputdata_file)
x, t = read_data(inputdata_file, typemap)

dim = [x.shape[1], 120, 50, 1]
model, optimizer = create_model2(dim)
serializers.load_npz(model_file_name, model)
serializers.load_npz(state_file_name, optimizer)

y = model.fwd(Variable(x)).data
print("expect actual  diff  acc")
for r in np.hstack([t, y, y - t, 1 - abs((y - t) / t)]):
  print("%6d %6d %5d %.2f" % (r[0], r[1], r[2], r[3]))

ac = (1 - abs(y - t) / t).mean()
print("total acc = %.3f" % ac)

d = 1 - abs(y - t) / t
d.sort(axis=0)
ac = d[:50].mean()
print("total acc = %.3f" % ac)
예제 #4
0
파일: run.py 프로젝트: hbrls/mx
# -*- coding: utf-8 -*-
from prepare import read_data, save_data, prepare_email
from prepare import validate_email, validate_password


if __name__ == "__main__":
    start = 35
    data = read_data('data_%s00000_%s00000.txt' % (start, start + 2), sep=" ")
    counter = 0
    good_counter = 0

    # http://technet.microsoft.com/en-us/library/gg524800.aspx
    with open('cleansed.txt', 'w') as cleansed, \
            open('dirty.txt', 'w') as dirty:
        for d in data:
            counter += 1
            if len(d) == 1:
                pass

            # ('*****@*****.**', '50537580')
            elif len(d) == 2:
                email, password = d
                if validate_password(password):
                    email = prepare_email(email)
                    if validate_email(email):
                        cleansed.write("%s\t%s\n" % (email, password))
                        good_counter += 1

            # ('597305222', '*****@*****.**', '13945560329')
            elif len(d) == 3 and d[0] in d[1]:
                email, password = d[1], d[2]
예제 #5
0
파일: main.py 프로젝트: mu853/aiclub
  markers = ["^", "o", "*", ".", ",", "v", ">", "<", "+", "1", "2"]
  colors = ["b", "g", "r", "c", "m", "y", "k", "w", "teal", "darkred", "indigo"]
  for i in range(num_of_hidden_layers):
    index = np.where(y == i)
    plt.scatter(lo[index], la[index], marker=markers[i], color=colors[i])

# parameters
mode = sys.argv[1]
datafile = sys.argv[2]
background_image = None
if len(sys.argv) > 3: background_image = sys.argv[3]
outputfile = None
if len(sys.argv) > 4: outputfile = sys.argv[4]

# read csv data
lo, la, data = read_data(datafile)

# plot
min_x = math.floor(min(lo) * 10) / 10
max_x = math.ceil(max(lo)  * 10) / 10
min_y = math.floor(min(la) * 10) / 10
max_y = math.ceil(max(la)  * 10) / 10
x_ticks = np.arange(min_x, max_x, 0.2) # x label
y_ticks = np.arange(min_y, max_y, 0.2) # y label
extent  = [min_x, max_x, min_y, max_y] # image size
plt.figure(figsize=(18,10)) # plot area size

subplot_rows = 2
subplot_cols = 4

num_of_hidden_layers_list = [2, 3, 4, 5, 6, 7, 8, 9]