Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Format data for predict().
tfjsRun = {
taskId,
taskType,
modelFormat,
modelName,
// TODO(cais): Add modelId.
functionName,
batchSize: pyRun.batchSize,
versionSetId,
environmentId: tfjsEnvironmentId,
numWarmUpIterations: pyRun.numWarmUpIterations,
numBenchmarkedIterations: pyRun.numBenchmarkedIterations,
timesMs: ts,
averageTimeMs: math.mean(ts),
endingTimestampMs: new Date().getTime()
};
console.log(
` (taskId=${taskId}) predict(): averageTimeMs: ` +
`py=${pyRun.averageTimeMs.toFixed(3)}, ` +
`tfjs=${tfjsRun.averageTimeMs.toFixed(3)}`);
} else if (functionName === 'fit') {
if (model instanceof tfconverter.GraphModel) {
throw new Error('GraphModel does not support training');
}
const pyFitLog = pyRun as ModelTrainingBenchmarkRun;
model.compile({
loss: LOSS_MAP[pyFitLog.loss],
optimizer: OPTIMIZER_MAP[pyFitLog.optimizer]
});
avgMinimum: 0,
reversed: true,
})
s.stats = growth
s.growth = growth > 1
s.stats2 = growth2
s.growth2 = growth2 > 1
s.stdevs = stats.stdev(tls)
s.stdevl = stats.stdev(tll)
s.means = math.mean(tls)
s.meanl = math.mean(tll)
s.pcts = s.stdevs / s.means
s.pctl = s.stdevl / s.meanl
s.options.markup_sell_pct = math.mean(s.pcts, s.pctl) * 100
s.options.markdown_buy_pct = math.mean(s.pcts, s.pctl) * 100
s.accel = growth > oldgrowth
oldgrowth = growth
}
if (s.growth === true && s.growth2 === true) {
s.signal = 'buy'
} else if (s.growth === false || s.growth2 === false || s.accel === false) {
// s.signal = 'sell'
}
cb()
},
onReport(s) {
sample({high, low}, n) {
// This assumes a 90% confidence interval, distributed symmetrically.
const mean = math.mean(high, low)
const stdev = (high - mean) / 1.645
return { values: Sample(n, () => jStat.normal.sample(mean, stdev)) }
}
}
mean: function(v) {
return m.mean(v);
},
// composition of mean•sumrow, i.e. mean of column vector of chunk
B = math.random([250 * 60, 8]);
var start = clock();
var cspParams = bci.math.cspLearn(A, B);
var Ap = bci.math.cspProject(cspParams, A);
var Bp = bci.math.cspProject(cspParams, B);
var end = clock(start);
times.push(end);
console.log(i + ' %');
}
console.log('Slowest ' + math.max(times) + ' ms');
console.log('Fastest ' + math.min(times) + ' ms');
console.log('Average ' + math.mean(times) + ' ms');
}
predictions.array.forEach(p => console.log(math.mean(p.array)));
}
//Learn
var predict = function (data) {
var x = new convnetjs.Vol(data);
var predicted_value = neural.net.forward(x);
return predicted_value.w[0];
}
this.HCL = (this.candle.high + this.candle.close + this.candle.open) / 3;
if (haspredicted & predictioncount > 1000) {
var item = Price;
prediction = predict(item)
mean = Price[Price.length - 1];
oldmean = prediction
meanp = math.mean(prediction, mean)
global.meanp = meanp
global.mean = mean
var percentvar = (meanp - mean) / mean * 100;
VarList.push(percentvar);
if (percentvar < 0) {
prediction += lowaccuracy;
percentvar += lowaccuracy;
if (lowpeak > percentvar) {
lowpeak = percentvar;
}
}
if (percentvar > 0) {
onPeriod(s, cb) {
ema(s, 'stddev', s.options.stddev)
const tl0 = []
const tl1 = []
if (s.lookback[s.options.min_periods]) {
for (let i = 0; i < s.options.trendtrades_1; i++) {
tl0.push(s.lookback[i].close)
}
for (let i = 0; i < s.options.trendtrades_2; i++) {
tl1.push(s.lookback[i].close)
}
s.std0 = stats.stdev(tl0) / 2
s.std1 = stats.stdev(tl1) / 2
s.mean0 = math.mean(tl0)
s.mean1 = math.mean(tl1)
s.sig0 = s.std0 > s.std1 ? 'Up' : 'Down'
s.sig1 = s.mean0 > s.mean1 ? 'Up' : 'Down'
}
if (s.sig1 === 'Down') {
s.signal = 'sell'
} else if (s.sig0 === 'Up' && s.sig1 === 'Up') {
s.signal = 'buy'
}
cb()
},
onReport(s) {
}
});
hitObjectsOnScreen.reverse();
time = replayPoints.next.offset;
}
if(allhits.length > 0)
unstablerate = variance(allhits) * 10;
if(earlyhits.length > 0)
errorearly = math.mean(earlyhits);
if(latehits.length > 0)
errorlate = math.mean(latehits);
cb(unstablerate);
});
});
function getMean(rowVector) {
const valuesWithoutZeroes = rowVector.filter(cell => cell !== 0);
return valuesWithoutZeroes.length ? math.mean(valuesWithoutZeroes) : 0;
}