Пример #1
0
def q3():
    # The shuffling is for test examples of skin and non skin
    # (without shuffling we test only non skins)
    examples = np.random.permutation(get_mat('Skin_NonSkin.txt')) 
    powers = 2**np.arange(-5, 16, 2.0)
    learning_part = 0.7
    learning, testing = np.split(examples, [examples.shape[0]*learning_part])
    C1, errors = find_c(powers, learning)
    error = sum([r[-1] * C1(r[:-1]) < 0 for r in testing])
    error /= testing.shape[0]
    return error, np.array([powers,errors])
Пример #2
0
def skin_mat():
    examples = np.random.permutation(get_mat('Skin_NonSkin.txt'))
    powers = 2**np.arange(-5, 16, 2.0)
    classifier, errors = find_c(powers, examples)

    img = misc.imread('image_0009.jpg')
    skin = np.array(img[..., 0])
    m, n = skin.shape
    for i in range(m):
        for j in range(n):
            r, g, b = img[i, j]
            s = classifier(np.array([b, g, r]))
            skin[i, j] = 255 if s > 0 else 0
    return skin
Пример #3
0
#
# Copyright © 2018 weihao <*****@*****.**>
#
# Distributed under terms of the MIT license.

from get_mat import get_mat
from get_pqrst import get_pqrst
from get_features import get_features
from get_ground_truth import get_result_for_classifier
from utils import *
from train import train
import pandas as pd

if __name__ == '__main__':
    data_used = 1000
    data = []
    #for i in range(1, 8529):
    for i in range(1, data_used):
        print(i)
        file_name = '../training2017/A%s.mat' % str(i).zfill(5)
        out = get_mat(file_name)
        ecg = out['filtered']
        P_index, Q_index, R_index, S_index, T_index = get_pqrst(out)
        features = get_features(ecg, P_index, Q_index, R_index, S_index,
                                T_index)
        data.append(flatten(features))

    df = pd.DataFrame(data=data)
    target = get_result_for_classifier('../training2017/REFERENCE.csv', 1)
    train(df, target[:data_used - 1])