本文整理汇总了Python中sklearn.cluster.DBSCAN.fit_transform方法的典型用法代码示例。如果您正苦于以下问题:Python DBSCAN.fit_transform方法的具体用法?Python DBSCAN.fit_transform怎么用?Python DBSCAN.fit_transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.cluster.DBSCAN
的用法示例。
在下文中一共展示了DBSCAN.fit_transform方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sklearn.cluster import DBSCAN [as 别名]
# 或者: from sklearn.cluster.DBSCAN import fit_transform [as 别名]
#.........这里部分代码省略.........
def simple_get_slots(self):
for d,day in enumerate(self.schedule):
for r,row in enumerate(day):
if(len(row) > 1):
is_parallel = True
else:
is_parallel = False
for c,col in enumerate(row):
if col == []:
slot_to_add = ClusterSlot()
slot_to_add.length = self.schedule_settings[d][r][c]
slot_to_add.coords = [d,r,c]
slot_to_add.is_parallel = is_parallel
self.slots.append(slot_to_add)
def create_dataset(self):
self.data_list = []
abstracts = []
titles = []
#print("VOCAB: ", self.vocab)
if self.vocab == []:
count_vectorizer = CountVectorizer(stop_words='english')
else:
count_vectorizer = CountVectorizer(vocabulary=self.vocab)
tfid_transformer = TfidfTransformer()
abstract_data = None
title_data = None
graph_data = None
for paper in self.papers:
abstracts.append(paper.paper.abstract)
titles.append(paper.paper.title)
if self.using_abstracts == True:
#print("using abstract data")
abstract_count = count_vectorizer.fit_transform(abstracts)
abstract_tfid = tfid_transformer.fit_transform(abstract_count)
abstract_data = abstract_tfid
#print(abstract_data)
if self.using_titles == True:
#print("using title data")
title_count = count_vectorizer.fit_transform(titles)
abstract_tfid = tfid_transformer.fit_transform(title_count)
title_data = abstract_tfid
#print(title_data.toarray(), len(self.papers))
if self.using_graph_data == True:
#print("using graph data")
graph_data = scipy.sparse.csr_matrix(np.matrix(self.graph_dataset))
#print(graph_data)
self.data = []
for paper in self.papers:
self.data.append([1])
self.data=scipy.sparse.csr_matrix(self.data)
#print("MAT ", self.data)
if abstract_data != None:
self.data = scipy.sparse.hstack([self.data, abstract_data])
if title_data != None:
self.data = scipy.sparse.hstack([self.data, title_data])
if graph_data != None:
self.data = scipy.sparse.hstack([self.data, graph_data])
# Reduce data to two dimensions
#print("nd data: ", self.data)
self.nd_data = self.data.toarray()
#print("SHAPE ", self.data.shape[1])
if self.data.shape[1] > 50:
svd_data = TruncatedSVD(n_components=50).fit_transform(self.data)
tsne_data = TSNE(n_components=2, metric='cosine').fit_transform(svd_data)
elif self.data.shape[1] < 10: