def run_iris(X, y, l, name, plot_lambda=False): #iris = datasets.load_iris() #X = iris.data #y = iris.target #X, y = make_classification(1000, 10) lambda_interval = np.linspace(0., 1., 11) time1 = time.clock() AWC_object = AWC(speed=1.) # To tune parameter \lambda, plot sum of the weights for \lambda 's from some interval #and take a value at the end of plateau or before huge jump. if plot_lambda == True: AWC_object.plot_sum_of_weights(lambda_interval, X) if l is None: l = 0.6 AWC_object.awc(l, X) clusters = AWC_object.get_clusters() labels = AWC_object.get_labels() time2 = time.clock() print(time2 - time1) draw(X, labels, name, True) print('Estimated number of clusters: %d' % len(set(labels))) print('cluster sizes: '), for c in clusters: print(len(c)), print("\nV-measure: %0.3f" % metrics.v_measure_score(y, labels))
class MixedXor: def __init__(self, j, k, m, initial, j2, k2, m2, initial2): self.first = AWC(j, k, m, initial) self.second = FibAdd(j2, k2, m2, initial2) def get_next(self): return self.first.get_next() ^ self.second.get_next()
def __init__(self, j, k, m, initial, j2, k2, m2, initial2): self.first = AWC(j, k, m, initial) self.second = FibAdd(j2, k2, m2, initial2)