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

Method _map_predictions

bertopic/_bertopic.py:3901–3905  ·  view source on GitHub ↗

Map predictions to the correct topics if topics were reduced.

(self, predictions: List[int])

Source from the content-addressed store, hash-verified

3899 return documents
3900
3901 def _map_predictions(self, predictions: List[int]) -> List[int]:
3902 """Map predictions to the correct topics if topics were reduced."""
3903 mappings = self.topic_mapper_.get_mappings(original_topics=True)
3904 mapped_predictions = [mappings[prediction] if prediction in mappings else -1 for prediction in predictions]
3905 return mapped_predictions
3906
3907 def _reduce_dimensionality(
3908 self,

Callers 1

transformMethod · 0.95

Calls 1

get_mappingsMethod · 0.80

Tested by

no test coverage detected