コード例 #1
0
ファイル: zmltests.py プロジェクト: flair2005/Automoculus
def load_data():
    return getDataMatrix(TRAIN_FILES)
コード例 #2
0
ファイル: zmltests.py プロジェクト: flair2005/Automoculus
            scores.append(score)
            #train_score = np.sum(np.abs(clf.predict(X_scaled) - y)) / len(y)
            train_score = np.sum(clf.predict(X_scaled) == y) / len(y)
            train_scores.append(train_score)
            lengths.append(len(y))
            print("{:.4}\t\t{:.4}".format(train_score, score))

    print( np.sum(np.array(scores) * np.array(lengths))/np.sum(lengths))
    print(np.mean(scores))
"""



if __name__ == "__main__":
    results = []
    X, y = getDataMatrix(TRAIN_FILES)
    scaler = preprocessing.Scaler()
    scaler.fit(X)
    
    for i, f in enumerate(TRAIN_FILES):
        X, y = getDataMatrix(TRAIN_FILES[:i] + TRAIN_FILES[i+1:])
        X_scaled = scaler.transform(X)
        clf = linear_model.LogisticRegression(C=0.04)
        clf.fit(X_scaled, y)

        s1 = test(f, use_classified_shot=True)
        s2 = test(f, use_classified_shot=False)
        #s3 = test(f, use_classified_shot=False, use_history=False)
        print(("{:.2%}\t\t"*2).format(s1, s2))
        results.append((s1, s2))
    r = np.array(results)