Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added checks for relative input shapes in linear regression using the utility introduced in #2370 #3640

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lumi232
Copy link

@lumi232 lumi232 commented Feb 27, 2024

This PR implements the solution mentioned in the issue #2820 by using the CheckSameSizes and CheckSameDimensionality utilities in src/mlpack/methods/linear_regression/linear_regression_train_main.cpp
src/mlpack/methods/linear_regression/linear_regression_main.cpp and
src/mlpack/methods/linear_regression/linear_regression_predict_main.cpp
All the if statements mentioned in #2370 (review) were replaced with the utility functions.

I plan to implement the solution to other methods as well once this PR is merged successfully. This is my first PR I look forward to contribute more to the organisation. Looking forward for the review.

Copy link

mlpack-bot bot commented Feb 27, 2024

Thanks for opening your first pull request in this repository! Someone will review it when they have a chance. In the mean time, please be sure that you've handled the following things, to make the review process quicker and easier:

  • All code should follow the style guide
  • Documentation added for any new functionality
  • Tests added for any new functionality
  • Tests that are added follow the testing guide
  • Headers and license information added to the top of any new code files
  • HISTORY.md updated if the changes are big or user-facing
  • All CI checks should be passing

Thank you again for your contributions! 👍

Copy link
Member

@rcurtin rcurtin left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @lumi232. Things look good to me; I think that all the builds will pass (don't mind the Windows build failure, it is unrelated). If you can handle the comments, I think we can get this merged. 👍

@@ -163,7 +163,7 @@ void BINDING_FUNCTION(util::Params& params, util::Timers& timer)
timer.Start("load_responses");
responses = params.Get<rowvec>("training_responses");
timer.Stop("load_responses");

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

No need to add the whitespace (sorry, pedantic comment).

Copy link
Author

Choose a reason for hiding this comment

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

Sure I'll remove this

Copy link
Author

Choose a reason for hiding this comment

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

done @rcurtin

"training file." << std::endl;
}
util::CheckSameDimensionality(predictors, parameters.n_rows - 1,
"LinearRegression::ComputeError()", "predictors");
Copy link
Member

Choose a reason for hiding this comment

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

I believe we can remove the nRows variable now; it appears to be unused.

Copy link
Author

Choose a reason for hiding this comment

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

Sure I'll remove the nRows declaration.

Copy link
Author

Choose a reason for hiding this comment

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

done @rcurtin

try
{
util::CheckSameDimensionality(points, lr->Parameters().n_elem - 1,
"Linear Regression Prediction", "test points");
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure it's even necessary to keep this check---Predict() already has a CheckSameDimensionality() call inside it. So I think we can remove this (and the same for linear_regression_predict_main.cpp).

Copy link
Author

Choose a reason for hiding this comment

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

sure I'll remove this check

Copy link
Author

Choose a reason for hiding this comment

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

done @rcurtin

Copy link
Author

Choose a reason for hiding this comment

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

the build tests failed upon removing this check I reverted this change and made a commit.

Copy link
Member

Choose a reason for hiding this comment

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

What did you try to debug the issue? "The build tests failed" is not a sufficient reason to give up on the comment here.

@lumi232
Copy link
Author

lumi232 commented Feb 27, 2024

@rcurtin I have made all the changes mentioned in the comments. The code is passing all the build tests (except windows). If there are any more changes do let me know. I'll move on to kmeans after this one is merged.

@lumi232 lumi232 force-pushed the linear_regression_added_shape_utility branch from 40676a7 to 9ecf0aa Compare February 28, 2024 05:56
@lumi232 lumi232 requested a review from rcurtin February 28, 2024 16:41
@lumi232
Copy link
Author

lumi232 commented Feb 29, 2024

Hey @rcurtin , can you please review this PR. I'll make the changes for other algorithms once this is merged so that we can close this issue(#2820) asap.

@lumi232
Copy link
Author

lumi232 commented Mar 3, 2024

@rcurtin can you review this PR.

Copy link

mlpack-bot bot commented Apr 2, 2024

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! 👍

@mlpack-bot mlpack-bot bot added the s: stale label Apr 2, 2024
@@ -163,7 +163,6 @@ void BINDING_FUNCTION(util::Params& params, util::Timers& timer)
timer.Start("load_responses");
responses = params.Get<rowvec>("training_responses");
timer.Stop("load_responses");

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, what I meant was that there was no need to replace the blank line with a line that has four spaces. I didn't mean that we should remove the line. 👍

try
{
util::CheckSameDimensionality(points, lr->Parameters().n_elem - 1,
"Linear Regression Prediction", "test points");
Copy link
Member

Choose a reason for hiding this comment

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

What did you try to debug the issue? "The build tests failed" is not a sufficient reason to give up on the comment here.

@mlpack-bot mlpack-bot bot removed the s: stale label Apr 8, 2024
Copy link

mlpack-bot bot commented May 8, 2024

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! 👍

@mlpack-bot mlpack-bot bot added the s: stale label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants