Beispiel #1
0
from src.good_radius import *
from numpy.random import normal
import numpy as np
import time
from numpy import round
from __non_private_cluster__ import find_cluster

sample_number = 2**12
center = 100
data_2d = round(normal(center, 50, (sample_number, 2)))
domain_end = max(abs(np.min(data_2d)), np.max(data_2d))
domain, goal_number = (domain_end, 1), 500
failure, eps, delta = 0.1, 0.5, 2**-20

r, c = find_cluster(data_2d, goal_number)
print "non-private radius : %d " % r
start_time = time.time()
result = find(data_2d, domain, goal_number, failure, eps)
print "run-time: %.2f seconds" % (time.time() - start_time)
print "good radius : %d " % result
points_in_resulting_ball = len(
    [i for i in data_2d if np.linalg.norm(i - (center, center)) <= result])
print "number of points in the resulting ball : %d" % points_in_resulting_ball
from src.good_radius import find
from numpy.random import normal
import numpy as np
import time
from numpy import round
from __non_private_cluster__ import find_cluster


sample_number = 2**11
center = 100
data_2d = round(normal(center, 50, (sample_number, 2)))
domain_end = max(abs(np.min(data_2d)), np.max(data_2d))
domain, goal_number = (domain_end, 1), 1000
failure, eps, delta = 0.1, 0.5, 2**-20

r, c = find_cluster(data_2d, goal_number)
print "non-private radius : %d " % r
start_time = time.time()
result = find(data_2d, domain, goal_number, failure, eps)
print "run-time: %.2f seconds" % (time.time() - start_time)
print "good radius : %d " % result
points_in_resulting_ball = len([i for i in data_2d if np.linalg.norm(i - (center, center)) <= result])
print "number of points in the resulting ball : %d" % points_in_resulting_ball
start_time = time.time()
result = find(data_2d, domain, goal_number, failure, eps, False)
print "run-time: %.2f seconds" % (time.time() - start_time)
print "good radius : %d " % result
points_in_resulting_ball = len([i for i in data_2d if np.linalg.norm(i - (center, center)) <= result])
print "number of points in the resulting ball : %d" % points_in_resulting_ball


sample_number = 5000
dimension = 20
blobs = dss.make_blobs(sample_number, dimension, cluster_std=50)
blob = np.round(blobs[0], 2)

approximation, failure, eps, delta = 0.1, 0.1, 0.5, 2**-10
domain_end = max(abs(np.min(blob)), np.max(blob))
domain = (domain_end, 0.01)
desired_amount_of_points = 1000

failure_bound = bound(sample_number, dimension, eps, delta, approximation)
print "The probability of failure is somewhere between %s\n" % str(failure_bound)

radius, center = find_cluster(blob, desired_amount_of_points)
print "Test-radius: %d" % radius

for i in xrange(8):
    middle_time = time.time()
    try:
        radius, center = cluster.find(blob, dimension, domain, desired_amount_of_points,
                                      approximation, failure, eps, delta, shrink=False, use_histograms=False)
        ball = [p for p in blob if euclidean(p, center) <= radius]
        print "Good-radius: %d" % radius
        # print "Good-center: %s" % str(center)
        print "Desired number of points in resulting ball: %d" % desired_amount_of_points
        print "Number of points in the resulting ball: %d" % len(ball)
    except ValueError:
        ball = []
        print '_|_'
Beispiel #4
0
# return here after good_radius_concave is complete
from src.good_radius import find
from src.good_radius_concave import find as find2
import numpy as np
import time
from __non_private_cluster__ import find_cluster
import sklearn.datasets as dss

sample_number = 3000
dimension, domain = 3, (0, 100)
blobs = dss.make_blobs(sample_number, dimension, cluster_std=70)
blob = blobs[0]

desired_amount_of_points, approximation, failure, eps, delta, promise = 1000, 0.1, 0.1, 0.5, 2**-10, 70

r, c = find_cluster(blob, desired_amount_of_points)
print r

start_time = time.time()
result = find(blob, domain, desired_amount_of_points, failure, eps)
print "run-time: %.2f seconds" % (time.time() - start_time)
print "good radius : %d " % result
points_in_resulting_ball = len(
    [i for i in blob if np.linalg.norm(i - (c, c)) < result])
print "number of points in the resulting ball : %d" % points_in_resulting_ball

start_time = time.time()
result = find2(blob, domain, desired_amount_of_points, failure, eps, delta,
               promise)
print "run-time: %.2f seconds" % (time.time() - start_time)
print "good radius : %d " % result
Beispiel #5
0
fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
ax = fig.add_subplot(211, aspect='equal')
zipped_data = zip(*blob)
ax.scatter(*zipped_data, c='g')
zipped_ball = zip(*ball)
ax.scatter(*zipped_ball, c='r')

print "Good-radius: %d" % radius
print "Good-center: %s" % str(center)
print "Desired number of points in resulting ball: %d" % desired_amount_of_points
print "Number of points in the resulting ball: %d" % len(ball)
print "Run-time: %.2f seconds" % (end_time - start_time)

start_time = time.time()
test_radius, test_center = find_cluster(blob, desired_amount_of_points)
end_time = time.time()
ball = [p for p in blob if euclidean(p, test_center) <= test_radius]
zipped_data = zip(*blob)
ax2 = fig.add_subplot(212, aspect='equal')
ax2.scatter(*zipped_data, c='b')
zipped_ball = zip(*ball)
ax2.scatter(*zipped_ball, c='r')

print "Test-radius: %d" % test_radius
print "Test-center: %s" % str(test_center)
print "Desired number of points in resulting ball: %d" % desired_amount_of_points
print "Number of points in the resulting ball: %d" % len(ball)
print "Run-time: %.2f seconds" % (end_time - start_time)

plt.show()
from src.good_radius import find
from src.good_radius_concave import find as find2
import numpy as np
import time
from __non_private_cluster__ import find_cluster
import sklearn.datasets as dss


sample_number = 3000
dimension, domain = 3, (0, 100)
blobs = dss.make_blobs(sample_number, dimension, cluster_std=70)
blob = blobs[0]

desired_amount_of_points, approximation, failure, eps, delta, promise = 1000, 0.1, 0.1, 0.5, 2**-10, 70

r, c = find_cluster(blob, desired_amount_of_points)
print r

start_time = time.time()
result = find(blob, domain, desired_amount_of_points, failure, eps)
print "run-time: %.2f seconds" % (time.time() - start_time)
print "good radius : %d " % result
points_in_resulting_ball = len([i for i in blob if np.linalg.norm(i - (c, c)) < result])
print "number of points in the resulting ball : %d" % points_in_resulting_ball

start_time = time.time()
result = find2(blob, domain, desired_amount_of_points, failure, eps, delta, promise)
print "run-time: %.2f seconds" % (time.time() - start_time)
print "good radius : %d " % result
points_in_resulting_ball = len([i for i in blob if np.linalg.norm(i - (c, c)) < result])
print "number of points in the resulting ball : %d" % points_in_resulting_ball