-
Notifications
You must be signed in to change notification settings - Fork 342
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
Exclude all transitive dependencies of ssj
besides commons-math3
and replace linear regression implementation
#638
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,10 +46,10 @@ | |
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.stream.Collectors; | ||
import jenkins.util.SystemProperties; | ||
import org.apache.commons.math3.stat.regression.SimpleRegression; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
import org.kohsuke.stapler.bind.JavaScriptMethod; | ||
import umontreal.ssj.functionfit.LeastSquares; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uses libraries from |
||
import umontreal.ssj.functionfit.SmoothingCubicSpline; | ||
|
||
/** | ||
|
@@ -248,7 +248,13 @@ private void createLinearTrend( | |
if (history.size() < 3) { | ||
return; | ||
} | ||
double[] cs = LeastSquares.calcCoefficients(lrX, lrY); | ||
|
||
SimpleRegression sr = new SimpleRegression(true); | ||
for (int i = 0; i < lrX.length; i++) { | ||
sr.addData(lrX[i], lrY[i]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit awkward, but the |
||
} | ||
double intercept = sr.getIntercept(); | ||
double slope = sr.getSlope(); | ||
|
||
ObjectNode lrSeries = MAPPER.createObjectNode(); | ||
series.add(lrSeries); | ||
|
@@ -273,7 +279,7 @@ private void createLinearTrend( | |
} | ||
for (int index = 0; index < history.size(); ++index) { | ||
// Use float to reduce JSON size. | ||
lrData.add((float) (Math.round((cs[0] + index * cs[1]) * roundMul) / roundMul)); | ||
lrData.add((float) (Math.round((intercept + index * slope) * roundMul) / roundMul)); | ||
} | ||
} | ||
|
||
|
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 was already a dependency via
ssj
, I think it was just unused previously, but now we use it forSimpleRegression
.