-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Isotonic Regression #223
Isotonic Regression #223
Conversation
impl Default for IsotonicRegression { | ||
fn default() -> Self { | ||
IsotonicRegression::new() | ||
} | ||
} |
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.
This can just be derived
assert_eq!(y.dim(), n_samples); | ||
|
||
// use correlation for determining relationship between x & y | ||
let x = X.slice(s![.., 0]); |
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.
Do X.col(0)
// use correlation for determining relationship between x & y | ||
let x = X.slice(s![.., 0]); | ||
let rho = DatasetBase::from(stack![Axis(1), x, y]).pearson_correlation(); | ||
let incresing = rho.get_coeffs()[0] >= F::zero(); |
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.
increasing
let mut i0 = B_zero.2.clone(); | ||
i0.extend(&(B_plus.2)); | ||
J[i] = (v0, w0, i0); | ||
J.remove(i + 1); |
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.
Vector removal is O(n), which is inefficient inside loops. Can you change J
to a different data structure so removals are less expensive? Hashmap
or Vec<Option<...>>
are good options, but you'll need to change the way you index into J
.
I rewrote algorithm, and added an another implementation. |
What's the difference and tradeoffs between PVA and AlgorithmA? Is there a reason why we want to include both instead of just including one? If we really wanted both, then we should get rid of |
I removed AlgorithmA code, and left PVA code only. Both algorithms are of O(n) complexity, it's just AlgorithmA is dual to PVA, so the solutions they provide are almost similar. After all, I do not think we need two algorithms implemented. |
Mention the paper/textbook the algorithm is from in the public docs and you're good to go |
Codecov Report
@@ Coverage Diff @@
## master #223 +/- ##
==========================================
- Coverage 55.44% 55.38% -0.07%
==========================================
Files 95 96 +1
Lines 8774 8916 +142
==========================================
+ Hits 4865 4938 +73
- Misses 3909 3978 +69
Continue to review full report at Codecov.
|
An isotonic regression based the pool adjacent violators algorithm from Best, M.J., Chakravarti, N. Active set algorithms for isotonic regression; A unifying framework. Mathematical Programming 47, 425–439 (1990).