MCPcopy
hub / github.com/MaartenGr/BERTopic / BaseCluster

Class BaseCluster

bertopic/cluster/_base.py:4–41  ·  view source on GitHub ↗

The Base Cluster class. Using this class directly in BERTopic will make it skip over the cluster step. As a result, topics need to be passed to BERTopic in the form of its `y` parameter in order to create topic representations. Examples: This will skip over the cluster step

Source from the content-addressed store, hash-verified

2
3
4class BaseCluster:
5 """The Base Cluster class.
6
7 Using this class directly in BERTopic will make it skip
8 over the cluster step. As a result, topics need to be passed
9 to BERTopic in the form of its `y` parameter in order to create
10 topic representations.
11
12 Examples:
13 This will skip over the cluster step in BERTopic:
14
15 ```python
16 from bertopic import BERTopic
17 from bertopic.cluster import BaseCluster
18
19 empty_cluster_model = BaseCluster()
20
21 topic_model = BERTopic(hdbscan_model=empty_cluster_model)
22 ```
23
24 Then, this class can be used to perform manual topic modeling.
25 That is, topic modeling on a topics that were already generated before
26 without the need to learn them:
27
28 ```python
29 topic_model.fit(docs, y=y)
30 ```
31 """
32
33 def fit(self, X, y=None):
34 if y is not None:
35 self.labels_ = y
36 else:
37 self.labels_ = None
38 return self
39
40 def transform(self, X: np.ndarray) -> np.ndarray:
41 return X

Callers 2

fit_transformMethod · 0.90
_create_model_from_filesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected