PHP Class Camspiers\StatisticalClassifier\Classifier\SVM

Author: Cam Spiers ([email protected])
Inheritance: extends Classifier
Show file Open project: camspiers/statistical-classifier Class Usage Examples

Protected Properties

Property Type Description
$documentNormalizer Camspiers\StatisticalClassifier\Normalizer\Document\NormalizerInterface Takes document and makes it consistent
$threshold float | boolean
$tokenNormalizer Camspiers\StatisticalClassifier\Normalizer\Token\NormalizerInterface Takes tokenized data and makes it consistent or stem it
$tokenizer Camspiers\StatisticalClassifier\Tokenizer\TokenizerInterface Tokenizer (the way of breaking up documents)

Public Methods

Method Description
__construct ( Camspiers\StatisticalClassifier\DataSource\DataSourceInterface $dataSource, SVMModel $model = null, Camspiers\StatisticalClassifier\Normalizer\Document\NormalizerInterface $documentNormalizer = null, Camspiers\StatisticalClassifier\Tokenizer\TokenizerInterface $tokenizer = null, Camspiers\StatisticalClassifier\Normalizer\Token\NormalizerInterface $tokenNormalizer = null, SVM $svm = null, null $threshold = null )
classify ( $document )
getProbabilities ( string $document ) : array Returns the probabilities of the document being in each category
prepareModel ( )
setThreshold ( float $threshold ) Set the threshold probability a classifier document must meet

Protected Methods

Method Description
hasThreshold ( ) : boolean
prepareDocument ( string $document, SVMModel $model ) : array Formats the document for use in \SVMModel

Method Details

__construct() public method

public __construct ( Camspiers\StatisticalClassifier\DataSource\DataSourceInterface $dataSource, SVMModel $model = null, Camspiers\StatisticalClassifier\Normalizer\Document\NormalizerInterface $documentNormalizer = null, Camspiers\StatisticalClassifier\Tokenizer\TokenizerInterface $tokenizer = null, Camspiers\StatisticalClassifier\Normalizer\Token\NormalizerInterface $tokenNormalizer = null, SVM $svm = null, null $threshold = null )
$dataSource Camspiers\StatisticalClassifier\DataSource\DataSourceInterface
$model Camspiers\StatisticalClassifier\Model\SVMModel
$documentNormalizer Camspiers\StatisticalClassifier\Normalizer\Document\NormalizerInterface
$tokenizer Camspiers\StatisticalClassifier\Tokenizer\TokenizerInterface
$tokenNormalizer Camspiers\StatisticalClassifier\Normalizer\Token\NormalizerInterface
$svm SVM
$threshold null

classify() public method

public classify ( $document )

getProbabilities() public method

Returns the probabilities of the document being in each category
public getProbabilities ( string $document ) : array
$document string
return array

hasThreshold() protected method

protected hasThreshold ( ) : boolean
return boolean

prepareDocument() protected method

Formats the document for use in \SVMModel
protected prepareDocument ( string $document, SVMModel $model ) : array
$document string
$model Camspiers\StatisticalClassifier\Model\SVMModel
return array

prepareModel() public method

public prepareModel ( )

setThreshold() public method

Set the threshold probability a classifier document must meet
public setThreshold ( float $threshold )
$threshold float float value between 0-1

Property Details

$documentNormalizer protected property

Takes document and makes it consistent
protected NormalizerInterface,Camspiers\StatisticalClassifier\Normalizer\Document $documentNormalizer
return Camspiers\StatisticalClassifier\Normalizer\Document\NormalizerInterface

$threshold protected property

protected float|bool $threshold
return float | boolean

$tokenNormalizer protected property

Takes tokenized data and makes it consistent or stem it
protected NormalizerInterface,Camspiers\StatisticalClassifier\Normalizer\Token $tokenNormalizer
return Camspiers\StatisticalClassifier\Normalizer\Token\NormalizerInterface

$tokenizer protected property

Tokenizer (the way of breaking up documents)
protected TokenizerInterface,Camspiers\StatisticalClassifier\Tokenizer $tokenizer
return Camspiers\StatisticalClassifier\Tokenizer\TokenizerInterface