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)
Beispiel #2
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_transform():
    """Test transform of Kmeans"""
    covset = generate_cov(20, 3)
    km = Kmeans(2)
    km.fit(covset)
    km.transform(covset)
def test_Kmeans_predict():
    """Test prediction of Kmeans"""
    covset = generate_cov(20, 3)
    km = Kmeans(2)
    km.fit(covset)
    km.predict(covset)
def test_Kmeans_fit_parallel():
    """Test Fit of Kmeans using paralell"""
    covset = generate_cov(20, 3)
    km = Kmeans(2, n_jobs=2)
    km.fit(covset)
def test_Kmeans_fit_with_y():
    """Test Fit of Kmeans with a given y"""
    covset = generate_cov(20, 3)
    labels = np.array([0, 1]).repeat(10)
    km = Kmeans(2)
    km.fit(covset, y=labels)
def test_Kmeans_fit_with_init():
    """Test Fit of Kmeans wit matric initialization"""
    covset = generate_cov(20, 3)
    km = Kmeans(2, init=covset[0:2])
    km.fit(covset)
def test_Kmeans_fit():
    """Test Fit of Kmeans"""
    covset = generate_cov(20, 3)
    km = Kmeans(2)
    km.fit(covset)
Beispiel #9
0
    filtered_signal = np.expand_dims(filtered_signal, axis=0)
    epochs_data = np.concatenate((epochs_data, filtered_signal), axis=0)

    ## No Filtering
    # 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]))
Beispiel #10
0
def test_Kmeans_transform():
    """Test transform of Kmeans"""
    covset = generate_cov(20,3)
    km = Kmeans(2)
    km.fit(covset)
    km.transform(covset)
Beispiel #11
0
def test_Kmeans_predict():
    """Test prediction of Kmeans"""
    covset = generate_cov(20,3)
    km = Kmeans(2)
    km.fit(covset)
    km.predict(covset)
Beispiel #12
0
def test_Kmeans_fit_parallel():
    """Test Fit of Kmeans using paralell"""
    covset = generate_cov(20,3)
    km = Kmeans(2,n_jobs=2)
    km.fit(covset)
Beispiel #13
0
def test_Kmeans_fit_with_y():
    """Test Fit of Kmeans with a given y"""
    covset = generate_cov(20,3)
    labels = np.array([0,1]).repeat(10)
    km = Kmeans(2)
    km.fit(covset,y=labels)
Beispiel #14
0
def test_Kmeans_fit_with_init():
    """Test Fit of Kmeans wit matric initialization"""
    covset = generate_cov(20,3)
    km = Kmeans(2,init=covset[0:2])
    km.fit(covset)
Beispiel #15
0
def test_Kmeans_fit():
    """Test Fit of Kmeans"""
    covset = generate_cov(20,3)
    km = Kmeans(2)
    km.fit(covset)