\Camspiers\StatisticalClassifier\ClassifierSVM

Provides a text based SVM classifier which uses libsvm

Summary

Methods
Properties
Constants
__construct()
prepareModel()
classify()
setThreshold()
getProbabilities()
is()
setModel()
setDataSource()
No public properties found
No constants found
prepareDocument()
hasThreshold()
preparedModel()
applyTransform()
$tokenizer
$normalizer
$threshold
$dataSource
$model
N/A
No private methods found
No private properties found
N/A

Properties

$threshold

$threshold : float|bool

Type

float|bool

Methods

__construct()

__construct(\Camspiers\StatisticalClassifier\DataSource\DataSourceInterface $dataSource, \Camspiers\StatisticalClassifier\Model\SVMModel $model, \Camspiers\StatisticalClassifier\Tokenizer\TokenizerInterface $tokenizer, \Camspiers\StatisticalClassifier\Normalizer\NormalizerInterface $normalizer, \SVM $svm, null $threshold)

Parameters

\Camspiers\StatisticalClassifier\DataSource\DataSourceInterface $dataSource
\Camspiers\StatisticalClassifier\Model\SVMModel $model
\Camspiers\StatisticalClassifier\Tokenizer\TokenizerInterface $tokenizer
\Camspiers\StatisticalClassifier\Normalizer\NormalizerInterface $normalizer
\SVM $svm
null $threshold

prepareModel()

prepareModel() : null

Builds the model from the data source by applying transforms to the data source

Returns

null

classify()

classify( $document)

Parameters

$document

setThreshold()

setThreshold(float $threshold)

Set the threshold probability a classifier document must meet

Parameters

float $threshold

float value between 0-1

Throws

\InvalidArgumentException

getProbabilities()

getProbabilities(string $document) : array

Returns the probabilities of the document being in each category

Parameters

string $document

Returns

array

is()

is( $category,  $document)

Parameters

$category
$document

prepareDocument()

prepareDocument(string $document, \Camspiers\StatisticalClassifier\Model\SVMModel $model) : array

Formats the document for use in \SVMModel

Parameters

string $document
\Camspiers\StatisticalClassifier\Model\SVMModel $model

Returns

array

hasThreshold()

hasThreshold() : bool

Returns

bool

applyTransform()

applyTransform(callable $transform) : mixed

Take a callable and run it passing in any additionally specified arguments

Parameters

callable $transform

Throws

\RuntimeException

Returns

mixed