Пример #1
0
def runAndreaFeatures(path_train,path_test, path_features, dataset,n=1000,iter_num=5):
    features=[]
    with open(path_features,'r') as f_in:
        for line in f_in:
            for token in line.split():
                features.append(token)
    model = Perceptron.train_from_disk(path_train,dataset.get_classes_list() ,features[0:n], iter_num)
    print Perceptron.test_from_disk(model, path_test,features[0:n])
Пример #2
0
def runRainbowFeatures(path_train,path_test, path_features, dataset,n=1000,iter_num=5):
    features=[]
    with open(path_features,'r') as f_in:
        for line in f_in:
            features.append(line.split()[1])
    model = Perceptron.train_from_disk(path_train,dataset.get_classes_list() ,features[0:n], iter_num)
    for k,v in model.items():
        print k,v
    print Perceptron.test_from_disk(model, path_test,features[0:n])