Skip to content

Separate model selection#67

Merged
BerriJ merged 17 commits intomainfrom
separate_model_selection
Apr 25, 2025
Merged

Separate model selection#67
BerriJ merged 17 commits intomainfrom
separate_model_selection

Conversation

@simon-hirsch
Copy link
Copy Markdown
Owner

This is quite well now.

@simon-hirsch simon-hirsch requested review from BerriJ and Copilot April 23, 2025 18:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR separates model selection functionality by introducing a new log‐likelihood based information criterion function and refactoring the online GAMLSS estimator to support different model selection approaches. Key changes include:

  • Adding a new function, information_criterion_log_likelihood, to compute criteria based on log‐likelihood.
  • Refactoring model selection and beta update functions in online_gamlss.py with new parameters and renaming of iteration variables.
  • Updating convergence condition checks and internal data structures to support the new model selection logic.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/rolch/information_criteria.py Adds a log-likelihood based IC function to support additional criteria.
src/rolch/estimators/online_gamlss.py Refactors model selection methods and updates convergence conditions.
Comments suppressed due to low confidence (1)

src/rolch/estimators/online_gamlss.py:823

  • The updated convergence condition in the inner iteration now only checks 'it_inner > 1', which is not equivalent to the former cumulative condition (iteration_inner + iteration_outer >= 2). Please review this logic change to ensure it meets the intended convergence criteria.
if (abs(olddv - dv) <= self.abs_tol_inner) & (it_inner > 1):

Comment thread src/rolch/estimators/online_gamlss.py
@BerriJ BerriJ requested a review from Copilot April 24, 2025 12:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the information criterion functionality by replacing the old function‐based implementation with a new InformationCriterion class and updates related references across the codebase. Key changes include:

  • Converting the information criterion calculation from a function to a class with methods from_rss and from_ll.
  • Updating dependent modules (online_linear_model, init.py, and docs) to use the new class interface.
  • Removing the previous select_best_model_by_information_criterion function.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

File Description
src/rolch/information_criteria.py Replaces function with class implementation and updates docs.
src/rolch/estimators/online_linear_model.py Adapts model selection to use the new InformationCriterion class.
src/rolch/init.py Removes legacy function references and updates exports.
docs/model_selection.md Updates documentation reference to the new class.
Comments suppressed due to low confidence (2)

src/rolch/information_criteria.py:6

  • Typographical error: 'Calcuate' should be corrected to 'Calculate'.
    """Calcuate the information criteria.

src/rolch/information_criteria.py:14

  • The documentation table includes the 'max' criterion, but the init method does not accept 'max'. Please update the documentation or adjust the allowed criteria to resolve this inconsistency.
| "max" | Select the largest model           |                          |

@BerriJ
Copy link
Copy Markdown
Collaborator

BerriJ commented Apr 24, 2025

I did the following changes to this PR:

  • Removed: information_criterion, select_best_model_by_information_criterion and information_criterion_log_likelihood
  • Added a new class: InformationCriterion

Now we use InformationCriterion whenever we need to calculate an ic there are two methods from_rss and from_ll to calculate the ic from the residual sum of squares or from the log likelihood, respectively.
Also I removed select_best_model_by_information_criterion as it was basically a wrapper around best_ic = np.argmin(ic). Instead, we now use best_ic = np.argmin(ic) directly in gamlss and linearmodel.

@simon-hirsch
Copy link
Copy Markdown
Owner Author

Now we use InformationCriterion whenever we need to calculate an ic there are two methods from_rss and from_ll to calculate the ic from the residual sum of squares or from the log likelihood, respectively.
Also I removed select_best_model_by_information_criterion as it was basically a wrapper around best_ic = np.argmin(ic). Instead, we now use best_ic = np.argmin(ic) directly in gamlss and linearmodel.

What about EBIC and EFIC, see here: https://ieeexplore.ieee.org/abstract/document/10146465

@simon-hirsch simon-hirsch requested a review from Copilot April 25, 2025 09:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request refactors the model selection functionality by replacing the standalone functions with a dedicated InformationCriterion class.

  • Introduces the InformationCriterion class with methods for calculating criteria from RSS and log-likelihood values.
  • Updates references in estimator modules and documentation to use the new class.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

File Description
src/rolch/information_criteria.py Refactored information criterion functions into a class with methods from_rss and from_ll.
src/rolch/estimators/online_linear_model.py Updated model selection to use the InformationCriterion class instead of the removed functions.
src/rolch/init.py Removed deprecated function exports and exposes the new InformationCriterion class.
docs/model_selection.md Updated API documentation to reflect the change to the InformationCriterion class.

Comment thread src/rolch/information_criteria.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@BerriJ BerriJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lookgs good.

@BerriJ BerriJ merged commit b9327a9 into main Apr 25, 2025
23 checks passed
@BerriJ BerriJ deleted the separate_model_selection branch April 25, 2025 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants