# Path: LinearClassification/QDA_4_vowel.py
# def cookdata(inputs, outputs):
# def cal_pi(data_set, K, N):
# def cal_means(data_set, K, p):
# def cal_sigma(data_set, means, N, p):
# def discriminant(x, u, sigma, pi):
# def classify(x, U, S, P, K):
# def test(test_input, test_output, U, S, P, K):
#     N = len(train_input)
#     K = len(classes)


import numpy as np
import PhonemeLogistic as pl
from LinearClassification import QDA_4_vowel as qda
    train_index = index[0:i*part_size] + index[(i+1)*part_size:]
    train_in = data_in[train_index, :]
    train_out = data_out[train_index]
    return train_in, train_out, test_in, test_out

def cookdata(inputs, outputs):
    train_inputs = {}
    M = 7
    N = 0
    for i in range(len(outputs)):
        train_inputs.setdefault(outputs[i], [])
        train_inputs[outputs[i]].append(inputs[i].tolist())
    for key in train_inputs.keys():
        cls = np.array(train_inputs[key])
        knots = createknots(1,256)
        p = len(cls[0])
        H = pl.basismatrix(knots, p, M)
        XS = pl.transform(H, cls, M)
        train_inputs[key] = XS
        N += len(XS)
    return train_inputs, N, M

if __name__ == '__main__':
    data_in, data_out = loaddata()
    error = 0.
    for i in range(10):
        dtrain_in, dtrain_out, dtest_in, dtest_out = split_data(data_in, data_out, i)
        train, N, p = cookdata(dtrain_in, dtrain_out)
        K = len(train)
        pi = qda.cal_pi(train, K, N)

# Path: LinearClassification/QDA_4_vowel.py
# def cookdata(inputs, outputs):
# def cal_pi(data_set, K, N):
# def cal_means(data_set, K, p):
# def cal_sigma(data_set, means, N, p):
# def discriminant(x, u, sigma, pi):
# def classify(x, U, S, P, K):
# def test(test_input, test_output, U, S, P, K):
#     N = len(train_input)
#     K = len(classes)


# Path: BasisExpansionsRegularization/PhonemeQDA.py
import numpy as np
import PhonemeLogistic as pl
from LinearClassification import QDA_4_vowel as qda

    train_index = index[0:i*part_size] + index[(i+1)*part_size:]
    train_in = data_in[train_index, :]
    train_out = data_out[train_index]
    return train_in, train_out, test_in, test_out

def cookdata(inputs, outputs):
    train_inputs = {}
    M = 7
    N = 0
    for i in range(len(outputs)):
        train_inputs.setdefault(outputs[i], [])
        train_inputs[outputs[i]].append(inputs[i].tolist())
    for key in train_inputs.keys():
        cls = np.array(train_inputs[key])
        knots = createknots(1,256)
        p = len(cls[0])
        H = pl.basismatrix(knots, p, M)
        XS = pl.transform(H, cls, M)
        train_inputs[key] = XS
        N += len(XS)
    return train_inputs, N, M

if __name__ == '__main__':
    data_in, data_out = loaddata()
    error = 0.
    for i in range(10):
        dtrain_in, dtrain_out, dtest_in, dtest_out = split_data(data_in, data_out, i)
        train, N, p = cookdata(dtrain_in, dtrain_out)
        K = len(train)
        pi = qda.cal_pi(train, K, N)

        means = qda.cal_means(train, K, p)