| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.100.1/docs/handbook/_sources/libraries/pca_projection.rst.txt |
.. _library_pca_projection:
pca_projection
Principal Component Analysis reducer for continuous datasets. The
library implements the dimension_reducer_protocol defined in the
dimension_reduction_protocols library and learns a linear projection
by centering the training data, optionally standardizing continuous
attributes, computing the covariance matrix, and extracting principal
components using deterministic power iteration with deflation.
Open the `../../apis/library_index.html#pca_projection <../../apis/library_index.html#pca_projection>`__ link in a web browser.
To load this library, load the loader.lgt file:
::
| ?- logtalk_load(pca_projection(loader)).
To test this library predicates, load the tester.lgt file:
::
| ?- logtalk_load(pca_projection(tester)).
component_N-Value pairs.The learn/3 predicate accepts the following options:
domain_error(component_count, Requested-Maximum). The default is
2.true (default) or
false.1000.1.0e-8.
The following examples use the sample datasets shipped with the
dimension_reduction_protocols library:
::
| ?- logtalk_load(dimension_reduction_protocols('test_datasets/correlated_plane')),
logtalk_load(dimension_reduction_protocols('test_datasets/high_dimensional_measurements')).
Learning a reducer ~~~~~~~~~~~~~~~~~~
::
| ?- pca_projection::learn(correlated_plane, DimensionReducer).
| ?- pca_projection::learn(correlated_plane, DimensionReducer, [n_components(1), feature_scaling(false), maximum_iterations(200), tolerance(1.0e-7)]).
Transforming new instances ~~~~~~~~~~~~~~~~~~~~~~~~~~
::
| ?- pca_projection::learn(high_dimensional_measurements, DimensionReducer),
pca_projection::transform(DimensionReducer, [f1-0.9, f2-1.1, f3-1.0, f4-2.0, f5-2.2, f6-2.1], ReducedInstance).
| ?- pca_projection::learn(correlated_plane, DimensionReducer, [n_components(1)]),
pca_projection::transform(DimensionReducer, [x-1.0, y-2.0, z-3.0], ReducedInstance).
Exporting and reusing the reducer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
| ?- pca_projection::learn(correlated_plane, DimensionReducer, [n_components(1)]),
pca_projection::export_to_file(correlated_plane, DimensionReducer, reducer, 'pca_reducer.pl').
| ?- logtalk_load('pca_reducer.pl'),
reducer(Reducer),
pca_projection::transform(Reducer, [x-1.0, y-2.0, z-3.0], ReducedInstance).
The learned dimension reducer is represented by a compound term with the functor chosen by the implementation and arity 4. For example:
::
pca_reducer(Encoders, Components, ExplainedVariances, Diagnostics)
Where:
Encoders: List of continuous attribute encoders storing attribute
name, mean, and scale.Components: List of principal direction vectors in descending
variance order.ExplainedVariances: List of eigenvalues matching the extracted
components.Diagnostics: Learned reducer metadata including the effective
training options and learned 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.