-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Multinomial logistic regression #159
Conversation
This reverts commit 2624bfd.
Codecov Report
@@ Coverage Diff @@
## master #159 +/- ##
==========================================
+ Coverage 59.84% 60.46% +0.62%
==========================================
Files 84 84
Lines 7748 7923 +175
==========================================
+ Hits 4637 4791 +154
- Misses 3111 3132 +21
Continue to review full report at Codecov.
|
would a review be helpful, despite being a draft? |
One observation I have of the multinomial implementation is that it tends to diverge when the input is not normalized well. Not sure if this is a natural property of the algorithm itself. |
The unnormalized wine quality also diverges on |
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.
nice work 👍
self.initial_params = Some((params, intercept)); | ||
/// The `params` array must have at least the same number of rows as there are columns on the | ||
/// feature matrix `x` passed to the `fit` method | ||
pub fn initial_params(mut self, params: Array<F, D>) -> Self { |
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.
doesn't this try to achieve what we are doing with FitWith
? (i.e. you can also initialize a linear model with these parameters and call fit_with
on that)
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 though FitWith
was meant to be used for "online" versions of algorithms for faster fitting? This method existed before so I just kept it. It has the same purpose as setting the initial centroids when using KMeans
, which is useful even when using FitWith
.
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.
yes, but I think it's more intuitive if a fitted model can be constructed (i.e. having a FittedLogisticRegression::new
function) with a given intercept and hyperplane. You can then update those initial weights with FitWith
instead of putting them to the hyperparameters.
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.
Both FittedLogisticRegression
and MultiFittedLogisticRegression
require the set of labels to be specified at construction, which isn't info that's available before fitting. If we make FitWith
perform a single iteration then the users will have to write their own loops and stopping conditions, which is more work. We could make FitWith
perform the complete algorithm to solve this. Also, if we have the Fit
version of the algorithm always start with param arrays of 0s, it'd be pretty much useless since the optimal starting params are random values, not 0s. I just don't think it makes sense to delegate the offline and online versions of the algorithm to the same impl. What we can do is have separate param types for the online and offline versions of the algorithm, both implementing FitWith
. The offline impl would run the entire algorithm while the online impl runs a single step. This makes sense because the offline algorithm requires a few hyperparams that the online version doesn't need.
Implementation of multinomial logistic regression. Also added some tests. Still need to add docs and possibly refactor.