Beispiel #1
0
def test_model(gm):
    full_csv_path = os.path.join(ARTIFACT_DIR, TEST_INFO_FILE)
    result = []
    with closing(open(full_csv_path, 'r')) as csvfile:
        dr = DictReader(csvfile)
        for row in dr:
            full_sample_path = os.path.join(ARTIFACT_DIR, row['filename'])
            feat = analyze.extract_features_file(full_sample_path)
            score = gm.score(feat)
            is_ok = row['is_ok'] == '1'
            result.append(TestResult(row['filename'], score, is_ok))
    return result
Beispiel #2
0
def generate_features():
    full_csv_path = os.path.join(ARTIFACT_DIR, TRAINING_INFO_FILE)
    feat_stacked = None
    with closing(open(full_csv_path, 'r')) as csvfile:
        dr = DictReader(csvfile)
        for row in dr:
            sample_path = os.path.join(ARTIFACT_DIR, row['filename'])
            feat = analyze.extract_features_file(sample_path)
            if feat_stacked is None:
                feat_stacked = feat
            else:
                feat_stacked = np.vstack((feat_stacked, feat))
    return feat_stacked
Beispiel #3
0
def create_features_data(filename):
    feat_finale = None
    labels_finale = None
    with closing(open(filename, 'r')) as csvfile:
        dr = DictReader(csvfile)
        for row in dr:
            feat = analyze.extract_features_file(row['filename'])
            labels = np.ones((feat.shape[0], 1)) * float(row['is_ok'])
            if feat_finale is None:
                feat_finale = feat
            else:
                feat_finale = np.vstack((feat_finale, feat))
            if labels_finale is None:
                labels_finale = labels
            else:
                labels_finale = np.vstack((labels_finale, labels))
    return feat_finale, labels_finale
Beispiel #4
0
def determine_from_sample(filename, clsfr):
    feat = analyze.extract_features_file(filename)
    return determine(clsfr, feat)
Beispiel #5
0
def sample_test(gm, sample_filename):
    feat = analyze.extract_features_file(sample_filename)
    return gm.score(feat)