Skip to content

Conversation

@georeth
Copy link
Contributor

@georeth georeth commented Nov 26, 2025

Checklist

  • My branch is up-to-date with development branch.
  • Everything works and tested on latest stable Rust.
  • Coverage and Linting have been applied

Current behaviour

Lasso::fit(X, y) with square X fails.

New expected behaviour

allow n==p case

Change logs

LASSO

  • change loss function in doc to match code
  • allow n == p case

* change loss function in doc to match code
* allow `n == p` case
@georeth georeth requested a review from Mec-iS as a code owner November 26, 2025 03:22
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.77%. Comparing base (70d8a0f) to head (195d893).
⚠️ Report is 4 commits behind head on development.

Additional details and impacted files
@@               Coverage Diff               @@
##           development     #343      +/-   ##
===============================================
+ Coverage        45.59%   45.77%   +0.18%     
===============================================
  Files               93       93              
  Lines             8034     7958      -76     
===============================================
- Hits              3663     3643      -20     
+ Misses            4371     4315      -56     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@Mec-iS Mec-iS left a comment

Choose a reason for hiding this comment

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

please add a test specific for the behaviour as you have fixed it.

@georeth
Copy link
Contributor Author

georeth commented Nov 27, 2025

add a test case for n == p case.

please fix this line:

let w = Lasso::fit(&x, &y, param).unwrap().coefficients.unwrap().iter().copied().collect_vec(); // FIXME: better way?

The fit result is a column vector stored in a 2d array. I didn't figure out how to get a Vec from a DenseMatrix with only one column. get_col() returns ArrayView1 and take_col() returns DenseMatrix.

@Mec-iS
Copy link
Collaborator

Mec-iS commented Nov 27, 2025

thank you @georeth

I guess what you are looking for is:

let w: Vec<f64> = Lasso::fit(&x, &y, param)
    .unwrap()
    .coefficients()
    .iterator(0)
    .copied()
    .collect();

Please also run cargo fmt --all -- --check

@georeth
Copy link
Contributor Author

georeth commented Nov 27, 2025

fixed

@Mec-iS Mec-iS merged commit 2bf5f7a into smartcorelib:development Nov 28, 2025
13 checks passed
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.

2 participants