Skip to content

[SYSTEMDS-3681] Add stepGLM builtin function. - #2523

Open
Bruno-Ignaz wants to merge 15 commits into
apache:mainfrom
Bruno-Ignaz:main
Open

[SYSTEMDS-3681] Add stepGLM builtin function.#2523
Bruno-Ignaz wants to merge 15 commits into
apache:mainfrom
Bruno-Ignaz:main

Conversation

@Bruno-Ignaz

Copy link
Copy Markdown

Hi,
This is a homework pull-requests for the course AMLs at TUB.
This is also my first pull-request :)

I refactored ./scripts/algorithm/StepGLM.dml into a importable function.

  • Over 900 lines of code removed
  • Replacement of global variables with function parameters
  • Replacement of custom GLM solver glm_fit with adapter that uses the builtin solver m_gml from ./scripts/builtin/gml.dml
  • Rewrite of the AIC calculation.

The probit inverse link function is now approximated (AIC calculation):

"it does not matter much whether one uses a probit model or a logit model, except in cases where data are heavily concentrated in the tails" (page 1487 in [1])

Additionally:

  • ./scripts/algorithms/TestBuiltinStepGLM.dml performs two checks for function output.

Sources

[1]: Takeshi, Qualitative Response Models: A Survey (1981)

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.66%. Comparing base (b150d8e) to head (b7e64b8).
⚠️ Report is 92 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2523      +/-   ##
============================================
+ Coverage     71.38%   71.66%   +0.27%     
- Complexity    48753    49336     +583     
============================================
  Files          1571     1580       +9     
  Lines        188912   190517    +1605     
  Branches      37067    37364     +297     
============================================
+ Hits         134857   136533    +1676     
+ Misses        43593    43464     -129     
- Partials      10462    10520      +58     

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@christinadionysio christinadionysio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for you PR, @Bruno-Ignaz!
I have a few minor things that should be improved before we can push your code into the upstream. It would be appreciated if you could have a look.

if (nrow(B) != 3 | sum(beta_est != 0 & beta_true == 0) > 0 | sum(beta_est == 0 & beta_true != 0) > 0) {
stop("Test failed: Inexact feature support recovery.");
}
print("passed test 1")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be great if we could create two tests that are called from the BuiltinSTEPGlmTest.java so that we know exactly which test is failing without the need for print statements.




#stop("!!!Sucess!!!") # uncomment for letting the test fail

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

if (max(abs(beta_est - beta_true)) > epsilon) {
stop("Test failed: Parameter estimates exceed tolerance bound epsilon = " + epsilon + ".");
}
print("passed test 2")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above, create specific test case that is called from the java test suite, and remove the print statement.

all_ones = matrix (1, rows = num_records, cols = 1);
[AIC_best, ignore_beta2, ignore_S2] = internal_glm(X=all_ones, Y=Y, intercept_status=0, num_features_orig=num_features, Selected=columns_fixed_ordered, link=link, disp=disp, tol=tol, moi=moi, mii=mii);
}
#print ("Best AIC without any features: " + AIC_best);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove this line

}

if (column_best == 0) {
#print ("AIC of an empty model is " + AIC_best + " and adding no feature achieves more than " + (thr * 100) + "% decrease in AIC!");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

}
};

# print ("Best AIC " + AIC_best + " achieved with feature: " + column_best);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove this line.

[AIC_best, ignore_beta4, ignore_S4] = internal_glm(X=X_global, Y=Y, intercept_status=0, num_features_orig=num_features, Selected=columns_fixed_ordered, link=link, disp=disp, tol=tol, moi=moi, mii=mii);
} else {
# compute AIC of an empty model with only intercept (all Ys are constant)
###all_ones = matrix (1, rows = num_records, cols = 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be removed as well.


# cbind best found features (i.e., columns) to X_global
if (as.scalar(columns_fixed[1,column_best]) == 0) { # new best feature found
#print ("Best AIC " + AIC_best + " achieved with feature: " + column_best);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Delete

}

# run GLM with selected set of features
print ("Running GLM with selected features...");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please do not add print statements.


[AIC, B, S] = stepGLM::m_stepGLM(X=X, Y=Y, link=2, yneg=0.0, icpt=0, tol=1e-6, disp=0.0, moi=200, mii=0, thr=0.01);

print("\n\n\n\n\n\n\nTest Results:");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please remove the print statements.

@github-project-automation github-project-automation Bot moved this from In Progress to In Review in SystemDS PR Queue Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants