import numpy as np
import pandas as pd
import math
import random

from sklearn.neighbors import NearestNeighbors
from sklearn.cluster import DBSCAN

from matplotlib import pyplot as plt

import Meeting10.BFS.functions as fs

#X = fs.getTINSData()
#labelsMatrix = np.genfromtxt("TINSlabels.csv", delimiter=",")

X = fs.getGenData()
labelsMatrix = np.genfromtxt("GENlabels.csv", delimiter=",")

n = 25
xStart = -5
#xEnd = 5
xEnd = 15
yStart = 15
yEnd = -10
xIteration = (xEnd - xStart) / n
yIteration = (yEnd - yStart) / n
labelsX = fs.delabeling(X, labelsMatrix, n, xStart, xEnd, yStart, yEnd)

LABEL_COLOR_MAP = {
    -1: 'white',
    0: 'w',
예제 #2
0
from sklearn.cluster import DBSCAN
from sklearn.cluster import KMeans

sys.setrecursionlimit(100000)

import Meeting10.BFS.functions as fs
import Meeting10.BFS.benchmarking as f

n = 25

# X = np.genfromtxt("unbalance.csv", delimiter=",")
# X = np.genfromtxt("s1_labeled.csv", delimiter=",")
# X = np.genfromtxt("s2_labeled.csv", delimiter=",")
# X, y = X[:, [0,1]], X[:, 2]
X, y = fs.getGenData()

start = timer()
# kmeans = KMeans(n_clusters=8).fit(X) #unbalanced
kmeans = KMeans(n_clusters=15).fit(X)  #s1, s2
kmeans = KMeans(n_clusters=4).fit(X)  #gen

labels = kmeans.labels_
end = timer()
f.benchmark(labels, y)
print("KMEANS TIME: " + str(end - start))

#eps = 5000 #unbalanced
#min_samples=np.log(len(X)) #unbalanced
# eps = 45000 #s2
# min_samples=np.log(len(X))*10 #s2