.. index:: single: lasso_feature_selector
.. _lasso_feature_selector/0:

.. rst-class:: right

**object**

``lasso_feature_selector``
==========================

Regression feature selection by maximum absolute Lasso coefficient per original feature, with optional deterministic holdout regularization search. Search requires two usable rows.

| **Availability:** 
|    ``logtalk_load(lasso_feature_selector(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-10-07

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Imports:**
|    ``public`` :ref:`feature_selector_common <feature_selector_common/0>`
| **Uses:**
|    :ref:`format <format/0>`
|    :ref:`lasso_regression <lasso_regression/0>`
|    :ref:`list <list/0>`
|    :ref:`regression_dataset_adapter(Dataset) <regression_dataset_adapter/1>`
|    :ref:`type <type/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|     :ref:`options_protocol/0::check_option/1`  :ref:`options_protocol/0::check_options/1`  :ref:`feature_selector_protocol/0::check_selector/1`  :ref:`options_protocol/0::default_option/1`  :ref:`options_protocol/0::default_options/1`  :ref:`feature_selector_protocol/0::diagnostic/2`  :ref:`feature_selector_protocol/0::diagnostics/2`  :ref:`feature_selector_protocol/0::export_to_clauses/4`  :ref:`feature_selector_protocol/0::export_to_file/4`  :ref:`feature_selector_protocol/0::feature_scores/2`  :ref:`feature_selector_protocol/0::learn/2`  :ref:`feature_selector_protocol/0::learn/3`  :ref:`options_protocol/0::option/2`  :ref:`options_protocol/0::option/3`  :ref:`feature_selector_protocol/0::print_selector/1`  :ref:`feature_selector_protocol/0::selected_features/2`  :ref:`feature_selector_protocol/0::selector_options/2`  :ref:`options_protocol/0::valid_option/1`  :ref:`options_protocol/0::valid_options/1`  :ref:`feature_selector_protocol/0::valid_selector/1`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

(no local declarations; see entity ancestors if any)

Protected predicates
--------------------

(no local declarations; see entity ancestors if any)

Private predicates
------------------

.. index:: usable_examples/3
.. _lasso_feature_selector/0::usable_examples/3:

``usable_examples/3``
^^^^^^^^^^^^^^^^^^^^^

Counts known numeric targets after shared dataset validation.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``usable_examples(Examples,Dataset,Count)``
| **Mode and number of proofs:**
|    ``usable_examples(+list(compound),+object_identifier,-non_negative_integer)`` - ``one_or_error``

| **Exceptions:**
|    A known target is not numeric:
|        ``type_error(number,Target)``
|    No known target remains:
|        ``domain_error(non_empty_examples,Dataset)``


------------

.. index:: count_numeric_targets/2
.. _lasso_feature_selector/0::count_numeric_targets/2:

``count_numeric_targets/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Counts numeric targets while skipping unbound targets.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``count_numeric_targets(Examples,Count)``
| **Mode and number of proofs:**
|    ``count_numeric_targets(+list(compound),-non_negative_integer)`` - ``one_or_error``

| **Exceptions:**
|    A known target is not numeric:
|        ``type_error(number,Target)``


------------

.. index:: check_search_count/1
.. _lasso_feature_selector/0::check_search_count/1:

``check_search_count/1``
^^^^^^^^^^^^^^^^^^^^^^^^

Requires at least two known numeric targets for holdout search.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``check_search_count(Count)``
| **Mode and number of proofs:**
|    ``check_search_count(+non_negative_integer)`` - ``one_or_error``

| **Exceptions:**
|    Fewer than two usable rows remain:
|        ``domain_error(lasso_search_examples,Count)``


------------

.. index:: group_scores/3
.. _lasso_feature_selector/0::group_scores/3:

``group_scores/3``
^^^^^^^^^^^^^^^^^^

Consumes exact encoder blocks and returns original feature scores in encoder order.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``group_scores(Encoders,Weights,Scores)``
| **Mode and number of proofs:**
|    ``group_scores(+list(compound),+list(float),-list(pair))`` - ``zero_or_one``


------------

.. index:: encoder_block/3
.. _lasso_feature_selector/0::encoder_block/3:

``encoder_block/3``
^^^^^^^^^^^^^^^^^^^

Returns an encoder name and its number of coefficient columns.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``encoder_block(Encoder,Feature,Count)``
| **Mode and number of proofs:**
|    ``encoder_block(+compound,-atom,-positive_integer)`` - ``zero_or_one``


------------

.. index:: block_maximum/5
.. _lasso_feature_selector/0::block_maximum/5:

``block_maximum/5``
^^^^^^^^^^^^^^^^^^^

Consumes a coefficient block and computes its maximum absolute weight.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``block_maximum(Count,Weights,Maximum0,Maximum,Remaining)``
| **Mode and number of proofs:**
|    ``block_maximum(+non_negative_integer,+list(float),+float,-float,-list(float))`` - ``zero_or_one``


------------

.. index:: select_active/3
.. _lasso_feature_selector/0::select_active/3:

``select_active/3``
^^^^^^^^^^^^^^^^^^^

Applies the selection strategy only to groups strictly above the coefficient cutoff.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``select_active(Scores,Options,Selected)``
| **Mode and number of proofs:**
|    ``select_active(+list(pair),+list(compound),-list(atom))`` - ``one``


------------

.. index:: active_scores/3
.. _lasso_feature_selector/0::active_scores/3:

``active_scores/3``
^^^^^^^^^^^^^^^^^^^

Retains scores strictly above the coefficient cutoff.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``active_scores(Scores,Cutoff,Active)``
| **Mode and number of proofs:**
|    ``active_scores(+list(pair),+number,-list(pair))`` - ``one``


------------

.. index:: model_diagnostics/8
.. _lasso_feature_selector/0::model_diagnostics/8:

``model_diagnostics/8``
^^^^^^^^^^^^^^^^^^^^^^^

Builds counts, effective options, aggregation metadata, and complete nested learner diagnostics.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``model_diagnostics(Regressor,Scores,Selected,OriginalCount,UsableCount,Options,SearchResult,Diagnostics)``
| **Mode and number of proofs:**
|    ``model_diagnostics(+compound,+list(pair),+list(atom),+positive_integer,+positive_integer,+list(compound),+term,-list(compound))`` - ``one``


------------

.. index:: valid_model/1
.. _lasso_feature_selector/0::valid_model/1:

``valid_model/1``
^^^^^^^^^^^^^^^^^

Checks the retained regressor and recomputes scores, selection, and metadata without binding a partial input.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``valid_model(Selector)``
| **Mode and number of proofs:**
|    ``valid_model(+ground)`` - ``zero_or_one``

| **Exceptions:**
|    The retained regressor is invalid:
|        ``domain_error(regressor,Regressor)``
|    A stored option is invalid:
|        ``domain_error(option,Option)``
|    A generated regularization bound exceeds backend floating-point limits:
|        ``evaluation_error(float_overflow)``
|    Stored options are not a list:
|        ``type_error(list,Options)``
|    A stored option is not compound:
|        ``type_error(compound,Option)``


------------

.. index:: store_regressor_options/3
.. _lasso_feature_selector/0::store_regressor_options/3:

``store_regressor_options/3``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Replaces the first nested options occurrence with the learner effective options, preserving later occurrences.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``store_regressor_options(Options,RegressorOptions,Stored)``
| **Mode and number of proofs:**
|    ``store_regressor_options(+list(compound),+list(compound),-list(compound))`` - ``one``


------------

.. index:: complete_regressor_options/2
.. _lasso_feature_selector/0::complete_regressor_options/2:

``complete_regressor_options/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Checks that each learner default option indicator has an effective value.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``complete_regressor_options(Defaults,Options)``
| **Mode and number of proofs:**
|    ``complete_regressor_options(+list(compound),+list(compound))`` - ``zero_or_one``


------------

.. index:: valid_regularization_grid/1
.. _lasso_feature_selector/0::valid_regularization_grid/1:

``valid_regularization_grid/1``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Checks an explicit penalty list or an increasing bounded linear grid with at least two candidates.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``valid_regularization_grid(Grid)``
| **Mode and number of proofs:**
|    ``valid_regularization_grid(@term)`` - ``zero_or_one``


------------

.. index:: regularization_grid_values/2
.. _lasso_feature_selector/0::regularization_grid_values/2:

``regularization_grid_values/2``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expands a validated linear grid to floating-point penalties or preserves an explicit penalty list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``regularization_grid_values(Grid,Values)``
| **Mode and number of proofs:**
|    ``regularization_grid_values(+term,-list(number))`` - ``one_or_error``

| **Exceptions:**
|    A generated bound exceeds backend floating-point limits:
|        ``evaluation_error(float_overflow)``


------------

Operators
---------

(none)

