| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.100.1/docs/handbook/_sources/libraries/kernel_svm_classifier.rst.txt |
.. _library_kernel_svm_classifier:
kernel_svm_classifierKernel support vector machine classifier using one-vs-rest dual margin models with linear, polynomial, and radial basis function kernels. The implementation encodes tabular datasets using the shared linear encoder pipeline so mixed continuous and categorical datasets are handled consistently with the existing linear classifiers.
The library implements the classifier_protocol defined in the
classification_protocols library. It provides predicates for
learning a classifier from a dataset, using it to make predictions,
estimating class probabilities, and exporting it as a list of predicate
clauses or to a file.
Datasets are represented as objects implementing the
dataset_protocol protocol from the classification_protocols
library. Continuous, categorical, and mixed-feature datasets are
supported.
Open the `../../docs/library_index.html#kernel_svm_classifier <../../docs/library_index.html#kernel_svm_classifier>`__ link in a web browser.
To load this library, load the loader.lgt file:
::
| ?- logtalk_load(kernel_svm_classifier(loader)).
To test this library predicates, load the tester.lgt file:
::
| ?- logtalk_load(kernel_svm_classifier(tester)).
linear,
polynomial(Degree, Gamma, Coef0), and rbf(Gamma) kernels.The learn/3 predicate supports these options:
linear)0.5)constant
or inverse_scaling(Power) (default: constant)25)1.0e-5)0.001)true)Learning a classifier ~~~~~~~~~~~~~~~~~~~~~
::
| ?- kernel_svm_classifier::learn(weather, Classifier).
| ?- kernel_svm_classifier::learn(mixed, Classifier, [kernel(rbf(0.5)), maximum_iterations(50)]).
Making predictions ~~~~~~~~~~~~~~~~~~
::
| ?- kernel_svm_classifier::learn(mixed, Classifier),
kernel_svm_classifier::predict(Classifier, [age-35, income-65000, student-yes, credit_rating-fair], Class).
| ?- kernel_svm_classifier::learn(weather, Classifier),
kernel_svm_classifier::predict_probabilities(Classifier, [outlook-sunny, temperature-hot, humidity-high, windy-false], Probabilities).
Exporting the classifier ~~~~~~~~~~~~~~~~~~~~~~~~
::
| ?- kernel_svm_classifier::learn(weather, Classifier),
kernel_svm_classifier::export_to_clauses(weather, Classifier, classify, Clauses).
| ?- kernel_svm_classifier::learn(weather, Classifier),
kernel_svm_classifier::export_to_file(weather, Classifier, classify, 'classifier.pl').
The learned classifier is represented as a compound term with the form:
::
kernel_svm_classifier(Classes, Encoders, Kernel, TrainingRows, Models, Options)
Where:
Classes: list of class labelsEncoders: list of continuous scaling descriptors and categorical
value encodersKernel: selected kernel specificationTrainingRows: encoded feature vectors for the training examplesModels: list of class_model(Class, Bias, Coefficients) termsOptions: merged training options used to learn the classifier
When exported using export_to_clauses/4 or export_to_file/4,
this classifier term is serialized directly as the single argument of
the generated predicate clause so that the exported model can be loaded
and reused as-is.