b4msa.classifier

class b4msa.classifier.SVC(model, **kwargs)[source]

Classifier

Parameters

model (class) – TextModel

Usage:

>>> from b4msa.textmodel import TextModel
>>> from b4msa.classifier import SVC
>>> corpus = ['buenos dias', 'catedras conacyt', 'categorizacion de texto ingeotec']
>>> textmodel = TextModel(corpus)
>>> svc = SVC(textmodel)
>>> _ = svc.fit([textmodel[x] for x in corpus], [1, 0, 0])
>>> svc.predict_text('hola')
0
fit(X, y)[source]

Train the classifier

Parameters
  • X (lst) – inputs - independent variables

  • y – output - dependent variable

Return type

instance

property num_terms

Dimension which is the number of terms of the corpus

Return type

int

tonp(X)[source]

Sparse representation to sparce matrix

Parameters

X (list) – Sparse representation of matrix

Return type

csr_matrix