| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.100.1/docs/handbook/_sources/libraries/lda_projection.rst.txt |
.. _library_lda_projection:
lda_projectionLinear Discriminant Analysis projection for labeled continuous datasets. Supports continuous attributes only.
The library implements the dimension_reducer_protocol defined in the
dimension_reduction_protocols library and learns discriminant
directions by centering the training data, optionally standardizing
continuous attributes, building regularized within-class and
between-class scatter matrices, whitening the Fisher criterion using a
Cholesky factorization, and extracting discriminant directions using
deterministic power iteration with deflation.
Requires a dataset implementing
supervised_dimension_reduction_dataset_protocol and therefore uses
class labels during training.
Open the `../../apis/library_index.html#lda_projection <../../apis/library_index.html#lda_projection>`__ link in a web browser.
To load this library, load the loader.lgt file:
::
| ?- logtalk_load(lda_projection(loader)).
To test this library predicates, load the tester.lgt file:
::
| ?- logtalk_load(lda_projection(tester)).
supervised_dimension_reduction_dataset_protocol and
containing only continuous attributes.component_N-Value pairs.The learn/3 predicate accepts the following options:
number_of_classes - 1 raise
domain_error(component_count, Requested-Maximum). The default is
2.true (default) or
false.1000.1.0e-8.1.0e-6.
The following examples use the sample labeled dataset shipped with the
dimension_reduction_protocols library:
::
| ?- logtalk_load(dimension_reduction_protocols('test_datasets/labeled_measurements')).
Learning a reducer ~~~~~~~~~~~~~~~~~~
::
| ?- lda_projection::learn(labeled_measurements, DimensionReducer).
| ?- lda_projection::learn(labeled_measurements, DimensionReducer, [n_components(1), feature_scaling(false), maximum_iterations(250), tolerance(1.0e-7), regularization(1.0e-5)]).
Transforming new instances ~~~~~~~~~~~~~~~~~~~~~~~~~~
::
| ?- lda_projection::learn(labeled_measurements, DimensionReducer),
lda_projection::transform(DimensionReducer, [length-5.1, width-3.5, height-1.4, weight-0.2], ReducedInstance).
| ?- lda_projection::learn(labeled_measurements, DimensionReducer, [n_components(1)]),
lda_projection::transform(DimensionReducer, [length-6.2, width-3.4, height-5.4, weight-2.3], ReducedInstance).
Exporting and reusing the reducer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
| ?- lda_projection::learn(labeled_measurements, DimensionReducer, [n_components(1)]),
lda_projection::export_to_file(labeled_measurements, DimensionReducer, reducer, 'lda_projection_reducer.pl').
| ?- logtalk_load('lda_projection_reducer.pl'),
reducer(Reducer),
lda_projection::transform(Reducer, [length-5.1, width-3.5, height-1.4, weight-0.2], ReducedInstance).
The learned dimension reducer is represented by a compound term with the functor chosen by the implementation and arity 4. For example:
::
lda_projection_reducer(Encoders, Components, ClassValues, Diagnostics)
Where:
Encoders: List of continuous attribute encoders storing attribute
name, mean, and scale.Components: List of learned discriminant vectors in component
order.ClassValues: Ordered list of class labels used during training.Diagnostics: Learned reducer metadata including the effective
training options and model details.
When exported using export_to_clauses/4 or export_to_file/4, this reducer 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.