nessie.models.text.sklean_text_classifier

Module Contents

Classes

SklearnTextClassifier

This model uses a sentence embedder like S-BERT to embed sentences, these are inputs to

Attributes

T

nessie.models.text.sklean_text_classifier.T
class nessie.models.text.sklean_text_classifier.SklearnTextClassifier(model_builder: Callable[[], T], embedder: nessie.models.featurizer.SentenceEmbedder)

Bases: nessie.models.TextClassifier, Generic[T]

This model uses a sentence embedder like S-BERT to embed sentences, these are inputs to train a model with scikit learn API.

__repr__(self)

Return repr(self).

__str__(self)

Return str(self).

fit(self, X: nessie.types.StringArray, y: nessie.types.StringArray)
label_encoder(self) sklearn.preprocessing.LabelEncoder

Returns a label encoder that can be used to map labels to ints and vice versa

name(self) str
predict(self, X: nessie.types.StringArray) numpy.typing.NDArray[str]
predict_proba(self, X: nessie.types.StringArray) numpy.typing.NDArray[float]

Returns a distribution over labels for each instance.

Parameters

X – The texts to predict on

Returns

A (num_instances, num_labels) numpy array

score(self, X: nessie.types.StringArray) numpy.typing.NDArray[float]

Returns the best score for each item