示例#1
0
def test_Kmeans_init():
    """Test Kmeans"""
    covset = generate_cov(20, 3)
    labels = np.array([0, 1]).repeat(10)

    # init
    km = Kmeans(2)

    # fit
    km.fit(covset)

    # fit with init
    km = Kmeans(2, init=covset[0:2])
    km.fit(covset)

    # fit with labels
    km.fit(covset, y=labels)

    # predict
    km.predict(covset)

    # transform
    km.transform(covset)

    # n_jobs
    km = Kmeans(2, n_jobs=2)
    km.fit(covset)
def test_Kmeans_init():
    """Test Kmeans"""
    covset = generate_cov(20, 3)
    labels = np.array([0, 1]).repeat(10)

    # init
    km = Kmeans(2)

    # fit
    km.fit(covset)

    # fit with init
    km = Kmeans(2, init=covset[0:2])
    km.fit(covset)

    # fit with labels
    km.fit(covset, y=labels)

    # predict
    km.predict(covset)

    # transform
    km.transform(covset)

    # n_jobs
    km = Kmeans(2, n_jobs=2)
    km.fit(covset)
def test_Kmeans_predict():
    """Test prediction of Kmeans"""
    covset = generate_cov(20, 3)
    km = Kmeans(2)
    km.fit(covset)
    km.predict(covset)
示例#4
0
    # raw_evoked_signal = evoked.data
    # raw_evoked_signal = np.array(raw_evoked_signal)
    # raw_evoked_signal = np.expand_dims(raw_evoked_signal, axis=0)

    cov_ext_trials = Covariances(estimator='lwf').transform(epochs_data)

    ### TREINO ONLINE: AQUI NÃO FAZ SENTIDO
    #labels = np.append(labels, labels[count])

    # Fit a cada 4 janelas de tempo
    if (count % 4 == 0 and count != 0 and retrain == True):
        kmeans.fit(cov_ext_trials)
        print("RETRAINED")

    if (count > 5):
        prediction_labeled = kmeans.predict(cov_ext_trials)
    else:
        prediction_labeled = mdm.predict(cov_ext_trials)
    # Finish Time Counter
    time_2 = time.time()

    time_array.append(time_2 - time_1)
    count += 1
    print("Predictions: ")
    print(prediction_labeled[:32])
    print(prediction_labeled[32:])
    # print ("Label: " + str(labels[i]))
    print("Time: " + str(time_2 - time_1) + '\n')

    if count == 7:
        print("FIRST TEST")
示例#5
0
def test_Kmeans_predict():
    """Test prediction of Kmeans"""
    covset = generate_cov(20,3)
    km = Kmeans(2)
    km.fit(covset)
    km.predict(covset)