def transform(self, sdf_list): features = np.array([]) for file_ in sdf_list: #print file_ converted = SDF(file_) my_windows = np.array(converted.make_windows(self.W, self.S, self.FILTER)) prediction = histogramize(self.Kmeans_model.predict(my_windows), self.NUM_CLUSTERS) if len(features) == 0: features = prediction else: features = np.concatenate((features,prediction), axis=0) return features
def transform(self, sdf_list): features = np.array([]) for file_ in sdf_list: #print file_ converted = SDF(file_) my_windows = np.array( converted.make_windows(self.W, self.S, self.FILTER)) prediction = histogramize(self.Kmeans_model.predict(my_windows), self.NUM_CLUSTERS) if len(features) == 0: features = prediction else: features = np.concatenate((features, prediction), axis=0) return features
def fit(self, sdf_list, K): windows = np.array([]) for file_ in sdf_list: #print file_ converted = SDF(file_) my_windows = np.array(converted.make_windows(self.W, self.S, self.FILTER)) #print my_windows.shape if len(windows) == 0: windows = my_windows else: windows = np.concatenate((windows,my_windows), axis=0) self.Kmeans_model = KMeans(n_clusters=K) self.Kmeans_model.fit(windows) #print windows.shape, 'win shape' self.cluster_centers = self.Kmeans_model.cluster_centers_ return self.transform(sdf_list) #used to map back for sdf_class purposes/LSH pipeline
def fit(self, sdf_list, K): windows = np.array([]) for file_ in sdf_list: #print file_ converted = SDF(file_) my_windows = np.array( converted.make_windows(self.W, self.S, self.FILTER)) #print my_windows.shape if len(windows) == 0: windows = my_windows else: windows = np.concatenate((windows, my_windows), axis=0) self.Kmeans_model = KMeans(n_clusters=K) self.Kmeans_model.fit(windows) #print windows.shape, 'win shape' self.cluster_centers = self.Kmeans_model.cluster_centers_ return self.transform( sdf_list) #used to map back for sdf_class purposes/LSH pipeline