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_predict():
    """Test prediction of Kmeans"""
    covset = generate_cov(20, 3)
    km = Kmeans(2)
    km.fit(covset)
    km.predict(covset)
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_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_init():
    """Test init of Kmeans"""
    km = Kmeans(2)
def test_Kmeans_fit():
    """Test Fit of Kmeans"""
    covset = generate_cov(20, 3)
    km = Kmeans(2)
    km.fit(covset)
Example #7
0
filtered_offline_signal = _bandpass_filter(offline_raw, frequencies,
                                           frequency_range)
offline_raw = createRaw(filtered_offline_signal, offline_raw, filtered=True)

offline_epochs = Epochs(offline_raw,
                        offline_events,
                        event_id,
                        tmin=2,
                        tmax=5,
                        baseline=None)
offline_epochs_data = offline_epochs.get_data()
labels = offline_epochs.events[:, -1]

epochs_data = offline_epochs_data

kmeans = Kmeans(n_clusters=4)

time_array = []

print("\nlabels: ")
print(labels, "\n")

# first resolve an EEG stream on the lab network
print("looking for an EEG stream...")
streams = resolve_stream('name', 'openvibeSignal')
# create a new inlet to read from the stream
inlet = StreamInlet(streams[0])
sample, timestamp = inlet.pull_sample()
time_window = np.array(sample)
sample, timestamp = inlet.pull_sample()
sample = np.array(sample)
Example #8
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)
Example #9
0
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_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)
Example #11
0
def test_Kmeans_predict():
    """Test prediction of Kmeans"""
    covset = generate_cov(20,3)
    km = Kmeans(2)
    km.fit(covset)
    km.predict(covset)
Example #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)
Example #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)
def test_Kmeans_transform():
    """Test transform of Kmeans"""
    covset = generate_cov(20, 3)
    km = Kmeans(2)
    km.fit(covset)
    km.transform(covset)
Example #15
0
labels_base = copy.deepcopy(labels)
# Covariance Matrix transorm
off_cov_matrix = Covariances(estimator='lwf').transform(off_epochs_data)
# MDM model init and fit
mdm = MDM(metric=dict(mean='riemann', distance='riemann'))
mdm.fit(off_cov_matrix, labels)

# End of offline training

# EEG stream on the lab network
print("looking for an EEG stream...")
streams = resolve_stream('name', 'openvibeSignal')
# Create a new inlet to read from the stream
inlet = StreamInlet(streams[0])

kmeans = Kmeans(n_clusters=4)

time_window = timeWindowInit(inlet)
time_window_base = copy.deepcopy(time_window)
timeBase = time.time()

count = 0
time_array = []
while not keyboard.is_pressed('s'):
    time_window = copy.deepcopy(time_window_base)
    while time_window.shape[1] < 769:
        sample, timestamp = inlet.pull_sample()
        sample = np.array(sample)
        time_window = np.column_stack((time_window, sample))

    actualTime = time.time() - timeBase
Example #16
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)
Example #17
0
def test_Kmeans_fit():
    """Test Fit of Kmeans"""
    covset = generate_cov(20,3)
    km = Kmeans(2)
    km.fit(covset)