本文整理匯總了Python中sklearn.cluster.Birch方法的典型用法代碼示例。如果您正苦於以下問題:Python cluster.Birch方法的具體用法?Python cluster.Birch怎麽用?Python cluster.Birch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.cluster
的用法示例。
在下文中一共展示了cluster.Birch方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: GetItemPixels
# 需要導入模塊: from sklearn import cluster [as 別名]
# 或者: from sklearn.cluster import Birch [as 別名]
def GetItemPixels(self, I):
'''
Locates items that should be picked up on the screen
'''
ws = [8, 14]
D1 = np.abs(I - np.array([10.8721, 12.8995, 13.9932])).sum(axis = 2) < 15
D2 = np.abs(I - np.array([118.1302, 116.0938, 106.9063])).sum(axis = 2) < 76
R1 = view_as_windows(D1, ws, ws).sum(axis = (2, 3))
R2 = view_as_windows(D2, ws, ws).sum(axis = (2, 3))
FR = ((R1 + R2 / np.prod(ws)) >= 1.0) & (R1 > 10) & (R2 > 10)
PL = np.transpose(np.nonzero(FR)) * np.array(ws)
if len(PL) <= 0:
return []
bc = Birch(threshold = 50, n_clusters = None)
bc.fit(PL)
return bc.subcluster_centers_
示例2: findClusters_Birch
# 需要導入模塊: from sklearn import cluster [as 別名]
# 或者: from sklearn.cluster import Birch [as 別名]
def findClusters_Birch(data):
'''
Cluster data using BIRCH algorithm
'''
# create the classifier object
birch = cl.Birch(
branching_factor=100,
n_clusters=4,
compute_labels=True,
copy=True
)
# fit the data
return birch.fit(data)
# the file name of the dataset
示例3: detection_with_birch
# 需要導入模塊: from sklearn import cluster [as 別名]
# 或者: from sklearn.cluster import Birch [as 別名]
def detection_with_birch(image_set):
"""
:param image_set: The bottleneck values of the relevant images.
:return: Predictions vector
"""
# The branching_factor, might be fine tune for better results
clf = cluster.Birch(n_clusters=2)
clf.fit(image_set)
predictions = clf.labels_
predictions = normalize_predictions(predictions)
return predictions
示例4: test_objectmapper
# 需要導入模塊: from sklearn import cluster [as 別名]
# 或者: from sklearn.cluster import Birch [as 別名]
def test_objectmapper(self):
df = pdml.ModelFrame([])
self.assertIs(df.cluster.AffinityPropagation, cluster.AffinityPropagation)
self.assertIs(df.cluster.AgglomerativeClustering, cluster.AgglomerativeClustering)
self.assertIs(df.cluster.Birch, cluster.Birch)
self.assertIs(df.cluster.DBSCAN, cluster.DBSCAN)
self.assertIs(df.cluster.FeatureAgglomeration, cluster.FeatureAgglomeration)
self.assertIs(df.cluster.KMeans, cluster.KMeans)
self.assertIs(df.cluster.MiniBatchKMeans, cluster.MiniBatchKMeans)
self.assertIs(df.cluster.MeanShift, cluster.MeanShift)
self.assertIs(df.cluster.SpectralClustering, cluster.SpectralClustering)
self.assertIs(df.cluster.bicluster.SpectralBiclustering,
cluster.bicluster.SpectralBiclustering)
self.assertIs(df.cluster.bicluster.SpectralCoclustering,
cluster.bicluster.SpectralCoclustering)
示例5: cluster_junctions
# 需要導入模塊: from sklearn import cluster [as 別名]
# 或者: from sklearn.cluster import Birch [as 別名]
def cluster_junctions(juncs):
birch_model = Birch(threshold=3, n_clusters=None)
X = np.array(juncs)
birch_model.fit(X)
return birch_model.labels_
示例6: __init__
# 需要導入模塊: from sklearn import cluster [as 別名]
# 或者: from sklearn.cluster import Birch [as 別名]
def __init__(self, options):
self.handle_options(options)
out_params = convert_params(
options.get('params', {}),
ints=['k'],
aliases={'k': 'n_clusters'},
)
self.estimator = _Birch(**out_params)
示例7: test_Birch
# 需要導入模塊: from sklearn import cluster [as 別名]
# 或者: from sklearn.cluster import Birch [as 別名]
def test_Birch(self):
Birch_algo.register_codecs()
self.clusterer_util(Birch)
示例8: __init__
# 需要導入模塊: from sklearn import cluster [as 別名]
# 或者: from sklearn.cluster import Birch [as 別名]
def __init__(self, similarity='cosine', decay_window=20, decay_alpha=0.25, clustering='dbscan', tagger='twitter', useful_tags=['Noun', 'Verb', 'Adjective', 'Determiner', 'Adverb', 'Conjunction', 'Josa', 'PreEomi', 'Eomi', 'Suffix', 'Alpha', 'Number'], delimiters=['. ', '\n', '.\n'], min_token_length=2, stopwords=stopwords_ko, no_below_word_count=2, no_above_word_portion=0.85, max_dictionary_size=None, min_cluster_size=2, similarity_threshold=0.85, matrix_smoothing=False, n_clusters=None, compactify=True, **kwargs):
self.decay_window = decay_window
self.decay_alpha = decay_alpha
if similarity == 'cosine': # very, very slow :(
self.vectorizer = DictVectorizer()
self.uniform_sim = self._sim_cosine
elif similarity == 'jaccard':
self.uniform_sim = self._sim_jaccard
elif similarity == 'normalized_cooccurrence':
self.uniform_sim = self._sim_normalized_cooccurrence
else:
raise LexRankError("available similarity functions are: cosine, jaccard, normalized_cooccurrence")
self.sim = lambda sentence1, sentence2: self.decay(sentence1, sentence2) * self.uniform_sim(sentence1, sentence2)
self.factory = SentenceFactory(tagger=tagger, useful_tags=useful_tags, delimiters=delimiters, min_token_length=min_token_length, stopwords=stopwords, **kwargs)
if clustering == 'birch':
self._birch = Birch(threshold=0.99, n_clusters=n_clusters)
self._clusterer = lambda matrix: self._birch.fit_predict(1 - matrix)
elif clustering == 'dbscan':
self._dbscan = DBSCAN()
self._clusterer = lambda matrix: self._dbscan.fit_predict(1 - matrix)
elif clustering == 'affinity':
self._affinity = AffinityPropagation()
self._clusterer = lambda matrix: self._affinity.fit_predict(1 - matrix)
elif clustering is None:
self._clusterer = lambda matrix: [0 for index in range(matrix.shape[0])]
else:
raise LexRankError("available clustering algorithms are: birch, markov, no-clustering(use `None`)")
self.no_below_word_count = no_below_word_count
self.no_above_word_portion = no_above_word_portion
self.max_dictionary_size = max_dictionary_size
self.similarity_threshold = similarity_threshold
self.min_cluster_size = min_cluster_size
self.matrix_smoothing = matrix_smoothing
self.compactify = compactify