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
base: master
Are you sure you want to change the base?
Added checks for relative input shapes in linear regression using the utility introduced in #2370 #3640
Conversation
…tatements to check input shapes
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:
Thank you again for your contributions! 👍 |
There was a problem hiding this 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"); | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add the whitespace (sorry, pedantic comment).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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
).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done @rcurtin
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@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. |
40676a7
to
9ecf0aa
Compare
@rcurtin can you review this PR. |
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! 👍 |
@@ -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"); | |||
|
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
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! 👍 |
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.