Created
December 7, 2019 11:10
-
-
Save malakhov-dmitrii/b3826a0f1c4ddf80d6c592a21014b39b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const adjustParams = (period) => { | |
const iter = 10; | |
const incr = 1 / iter; | |
let bestAlpha = 0.0; | |
let bestError = -1; | |
let alpha = bestAlpha; | |
let bestGamma = 0.0; | |
let gamma = bestGamma; | |
let bestDelta = 0.0; | |
let delta = bestDelta; | |
while (alpha < 1) { | |
while (gamma < 1) { | |
while (delta < 1) { | |
const pred = this.predict(data, alpha, delta, gamma, period); | |
const error = this.computeMeanSquaredError(data, pred); | |
if (error < bestError || bestError === -1) { | |
bestAlpha = alpha; | |
bestGamma = gamma; | |
bestDelta = delta; | |
bestError = error; | |
} | |
delta += incr; | |
} | |
delta = 0; | |
gamma += incr; | |
} | |
gamma = 0; | |
alpha += incr; | |
} | |
alpha = bestAlpha; | |
gamma = bestGamma; | |
delta = bestDelta; | |
return { | |
alpha, | |
gamma, | |
delta, | |
bestError, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment