Predictions Stored at Trading Engine
This commit is contained in:
1 parent
7d5a997272
commit
48361c8e89
4 files changed
+216
-55
No files matched your search
@@ -1 +1 @@
|
||||
{"type":"Learning Engine","name":"Low-Frequency","project":"Superalgos","learningCurrent":{"type":"Learning Current","name":"New Learning Current","project":"Superalgos","learningEpisode":{"type":"Learning Episode","name":"New Learning Episode","project":"Superalgos","serialNumber":{"type":"Serial Number","name":"New Serial Number","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"2cc4ea2e-0c49-4dc4-be14-5c37dba3d4a3","savedPayload":{"position":{"x":11579.353376181454,"y":11483.233023771927},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"identifier":{"type":"Identifier","name":"New Identifier","config":"{\n\"initialValue\": \"\"\n}","project":"Superalgos","id":"5e87e4cf-d3cf-4ca3-90d0-bcc215ff32df","savedPayload":{"position":{"x":11553.745789630078,"y":11567.649923428959},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"begin":{"type":"Begin","name":"New Begin","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"7073b390-c791-428b-b75d-11d7bef076ee","savedPayload":{"position":{"x":11512.161325536144,"y":11645.44898372349},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"end":{"type":"End","name":"New End","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"f5dc8eea-94d7-41d7-9c44-3b044fa5cbb7","savedPayload":{"position":{"x":11456.198051533946,"y":11713.640430398615},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"beginRate":{"type":"Begin Rate","name":"New Begin Rate","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"f36a352e-9711-490f-9020-84bf3731f93c","savedPayload":{"position":{"x":11388.006604858821,"y":11769.603704400815},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"endRate":{"type":"End Rate","name":"New End Rate","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"0cd1e3ea-f314-4777-9988-bbde66dd2688","savedPayload":{"position":{"x":11310.207544564291,"y":11811.188168494748},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"status":{"type":"Status","name":"New Status","config":"{\n\"initialValue\": \"Not Open\"\n}","project":"Superalgos","id":"1961b061-f041-494f-8c47-004c672c23f3","savedPayload":{"position":{"x":11225.790644907258,"y":11836.795755046123},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"exitType":{"type":"Exit Type","name":"New Exit Type","config":"{\n\"initialValue\": \"No Exit\"\n}","project":"Superalgos","id":"9ffc4653-3d13-4036-b8aa-98e34ea6e497","savedPayload":{"position":{"x":11138,"y":11845.442378864669},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"headOfTheMarket":{"type":"Head Of The Market","name":"New Head Of The Market","config":"{\n\"initialValue\": false\n}","project":"Superalgos","id":"dc3294b4-3754-4154-808a-6531410f6378","savedPayload":{"position":{"x":11050.209355092742,"y":11836.795755046123},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"processDate":{"type":"Process Date","name":"New Process Date","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"a009dbfb-9fce-4787-9461-dc63cb0cdf03","savedPayload":{"position":{"x":10965.79245543571,"y":11811.188168494748},"targetPosition":{"x":11138,"y":11395.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"learningEpisodeCounters":{"type":"Learning Episode Counters","name":"New Learning Episode Counters","project":"Superalgos","periods":{"type":"Periods","name":"New Periods","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"74d652d9-7439-4a8f-a66e-588f1cb24686","savedPayload":{"position":{"x":10975.784040048437,"y":12210.957080582268},"targetPositLine truncated
|
||||
{"type":"Learning Engine","name":"Low-Frequency","project":"Superalgos","learningCurrent":{"type":"Learning Current","name":"New Learning Current","project":"Superalgos","learningEpisode":{"type":"Learning Episode","name":"New Learning Episode","project":"Superalgos","serialNumber":{"type":"Serial Number","name":"New Serial Number","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"2cc4ea2e-0c49-4dc4-be14-5c37dba3d4a3","savedPayload":{"position":{"x":11825.790644907258,"y":10354.089002683215},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"identifier":{"type":"Identifier","name":"New Identifier","config":"{\n\"initialValue\": \"\"\n}","project":"Superalgos","id":"5e87e4cf-d3cf-4ca3-90d0-bcc215ff32df","savedPayload":{"position":{"x":11910.207544564291,"y":10379.69658923459},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"begin":{"type":"Begin","name":"New Begin","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"7073b390-c791-428b-b75d-11d7bef076ee","savedPayload":{"position":{"x":11988.006604858821,"y":10421.281053328523},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"end":{"type":"End","name":"New End","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"f5dc8eea-94d7-41d7-9c44-3b044fa5cbb7","savedPayload":{"position":{"x":12056.198051533946,"y":10477.244327330722},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"beginRate":{"type":"Begin Rate","name":"New Begin Rate","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"f36a352e-9711-490f-9020-84bf3731f93c","savedPayload":{"position":{"x":12112.161325536144,"y":10545.435774005848},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"endRate":{"type":"End Rate","name":"New End Rate","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"0cd1e3ea-f314-4777-9988-bbde66dd2688","savedPayload":{"position":{"x":12153.745789630078,"y":10623.23483430038},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"status":{"type":"Status","name":"New Status","config":"{\n\"initialValue\": \"Not Open\"\n}","project":"Superalgos","id":"1961b061-f041-494f-8c47-004c672c23f3","savedPayload":{"position":{"x":12179.353376181454,"y":10707.651733957411},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"exitType":{"type":"Exit Type","name":"New Exit Type","config":"{\n\"initialValue\": \"No Exit\"\n}","project":"Superalgos","id":"9ffc4653-3d13-4036-b8aa-98e34ea6e497","savedPayload":{"position":{"x":12188,"y":10795.442378864669},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"headOfTheMarket":{"type":"Head Of The Market","name":"New Head Of The Market","config":"{\n\"initialValue\": false\n}","project":"Superalgos","id":"dc3294b4-3754-4154-808a-6531410f6378","savedPayload":{"position":{"x":12179.353376181454,"y":10883.233023771927},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"processDate":{"type":"Process Date","name":"New Process Date","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"a009dbfb-9fce-4787-9461-dc63cb0cdf03","savedPayload":{"position":{"x":12153.745789630078,"y":10967.649923428959},"targetPosition":{"x":11738,"y":10795.442378864669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":4,"arrangementStyle":0},"uiObject":{}}},"learningEpisodeCounters":{"type":"Learning Episode Counters","name":"New Learning Episode Counters","project":"Superalgos","periods":{"type":"Periods","name":"New Periods","config":"{\n\"initialValue\": 0\n}","project":"Superalgos","id":"74d652d9-7439-4a8f-a66e-588f1cb24686","savedPayload":{"position":{"x":10975.784040048437,"y":12210.957080582268},"targetPositLine truncated
|
||||
@@ -3039,9 +3039,125 @@
|
||||
"type": "node",
|
||||
"childType": "Learning Current",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "predictions",
|
||||
"type": "node",
|
||||
"childType": "Predictions",
|
||||
"autoAdd": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Predictions",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Prediction",
|
||||
"relatedUiObject": "Prediction",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
"confirmationLabel": "Confirm to Delete",
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
}
|
||||
],
|
||||
"addLeftIcons": true,
|
||||
"level": 3,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Learning Engine->"
|
||||
},
|
||||
"propertyNameAtParent": "predictions",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "predictions",
|
||||
"type": "array",
|
||||
"childType": "Prediction",
|
||||
"autoAdd": true
|
||||
}
|
||||
],
|
||||
"icon": "bitcoin"
|
||||
},
|
||||
{
|
||||
"type": "Prediction",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Configure",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration",
|
||||
"actionFunction": "uiObject.configEditor.activate"
|
||||
},
|
||||
{
|
||||
"action": "Add Missing Children",
|
||||
"label": "Add Missing Children",
|
||||
"relatedUiObject": "Learning Engine",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Copy Node Path",
|
||||
"label": "Copy Node Path",
|
||||
"iconPathOn": "copy-path",
|
||||
"iconPathOff": "copy-path",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Copy Node Value",
|
||||
"label": "Copy Node Value",
|
||||
"iconPathOn": "copy-value",
|
||||
"iconPathOff": "copy-value",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Copy Node Type",
|
||||
"label": "Copy Node Type",
|
||||
"iconPathOn": "copy-type",
|
||||
"iconPathOff": "copy-type",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
"confirmationLabel": "Confirm to Delete",
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
}
|
||||
],
|
||||
"editors": {
|
||||
"config": true
|
||||
},
|
||||
"initialValues": {
|
||||
"config": "{\n\"initialValue\": 0\n}"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 3,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Predictions->"
|
||||
},
|
||||
"propertyNameAtParent": "predictions",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "begin",
|
||||
"type": "node",
|
||||
"childType": "Begin",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "end",
|
||||
"type": "node",
|
||||
"childType": "End",
|
||||
"autoAdd": true
|
||||
}
|
||||
],
|
||||
"icon": "bitcoin"
|
||||
},
|
||||
{
|
||||
"type": "Dynamic Indicators",
|
||||
"menuItems": [
|
||||
@@ -7794,7 +7910,7 @@
|
||||
"addLeftIcons": true,
|
||||
"level": 3,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Trading Episode->Learning Episode->Strategy->Position->Candle->Cycle->Market Order->Limit Order->Strategy Trigger Stage->Strategy Open Stage->Strategy Manage Stage->Strategy Close Stage->Stop Loss->Take Profit->"
|
||||
"compatibleTypes": "->Trading Episode->Learning Episode->Strategy->Position->Candle->Cycle->Market Order->Limit Order->Strategy Trigger Stage->Strategy Open Stage->Strategy Manage Stage->Strategy Close Stage->Stop Loss->Take Profit->Prediction->"
|
||||
},
|
||||
"propertyNameAtParent": "begin"
|
||||
},
|
||||
@@ -7848,7 +7964,7 @@
|
||||
"addLeftIcons": true,
|
||||
"level": 3,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Trading Episode->Learning Episode->Strategy->Position->Candle->Cycle->Market Order->Limit Order->Strategy Trigger Stage->Strategy Open Stage->Strategy Manage Stage->Strategy Close Stage->Stop Loss->Take Profit->"
|
||||
"compatibleTypes": "->Trading Episode->Learning Episode->Strategy->Position->Candle->Cycle->Market Order->Limit Order->Strategy Trigger Stage->Strategy Open Stage->Strategy Manage Stage->Strategy Close Stage->Stop Loss->Take Profit->Prediction->"
|
||||
},
|
||||
"propertyNameAtParent": "end"
|
||||
},
|
||||
@@ -10430,7 +10546,7 @@
|
||||
}
|
||||
],
|
||||
"initialValues": {
|
||||
"config": "{ \n\"codeName\": \"Time Series Forcasting Tensor Flow JS\"\n}"
|
||||
"config": "{ \n\"backLearningPredictingRatio\": 0.8\n}"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"editors": {
|
||||
|
||||
@@ -118,7 +118,8 @@ function newSuperalgosFunctionLibraryLearningSessionFunctions() {
|
||||
'Begin->End->Exit Type->Status->Begin Rate->End Rate->Stage Base Asset->Stage Quoted Asset->Size Placed->Target Size->Size Filled->Fees Paid->Stage Defined In->' +
|
||||
'Serial Number->Identifier->Begin->End->Begin Rate->End Rate->Strategy Name->Status->Exit Type->' +
|
||||
'Balance->Begin Balance->End Balance->' +
|
||||
'Index->Situation Name->Formula->Periods->'
|
||||
'Index->Situation Name->Formula->Periods->' +
|
||||
'Predictions->Prediction->Begin->End->'
|
||||
|
||||
let learningEngine = UI.projects.superalgos.functionLibraries.protocolNode.getProtocolNode(node.learningEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath)
|
||||
|
||||
|
||||
+94
-50
@@ -375,65 +375,109 @@ exports.newTensorFlowBotModulesTensorFlowLibrary = function (processIndex) {
|
||||
}
|
||||
|
||||
/*
|
||||
Building the Labels Tensor
|
||||
At this point we need to decide if we are going to learn or going to predict.
|
||||
This is regulated by the backLearningPredictingRatio property at the config
|
||||
of the Learning Algorithm of the Learning Session.
|
||||
*/
|
||||
if (layersModel.outputLayer === undefined) {
|
||||
// TODO
|
||||
}
|
||||
if (layersModel.outputLayer.outputLabels === undefined) {
|
||||
// TODO
|
||||
}
|
||||
learningSystem.evalFormulas(layersModel.outputLayer.outputLabels, layersModel.outputLayer.outputLabels.type)
|
||||
let backLearningPredictingRatio = 0.8 // this is the default value.
|
||||
|
||||
for (let i = 0; i < layersModel.outputLayer.outputLabels.dataLabels.length; i++) {
|
||||
let dataLabel = layersModel.outputLayer.outputLabels.dataLabels[i]
|
||||
if (dataLabel.labelFormula === undefined) { continue }
|
||||
let labelValue = learningSystem.formulas.get(dataLabel.labelFormula.id)
|
||||
labels.push(labelValue)
|
||||
}
|
||||
|
||||
tensorFlowData = require("@tensorflow/tfjs-data")
|
||||
|
||||
function* featuresGenerator() {
|
||||
//console.log('Features: ' + features)
|
||||
yield features
|
||||
}
|
||||
|
||||
function* labelsGenerator() {
|
||||
//console.log('Labels: ' + labels)
|
||||
yield labels
|
||||
}
|
||||
|
||||
const xs = tensorFlowData.generator(featuresGenerator)
|
||||
const ys = tensorFlowData.generator(labelsGenerator)
|
||||
const ds = tensorFlowData.zip({ xs, ys }).shuffle(1).batch(1)
|
||||
|
||||
let verbose = 0
|
||||
let ecpochs = 1
|
||||
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset !== undefined) {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose !== undefined) {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose.config.value !== undefined) {
|
||||
verbose = learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose.config.value
|
||||
}
|
||||
if (sessionParameters.learningAlgorithm !== undefined) {
|
||||
if (sessionParameters.learningAlgorithm.config.backLearningPredictingRatio !== undefined) {
|
||||
backLearningPredictingRatio = sessionParameters.learningAlgorithm.config.backLearningPredictingRatio
|
||||
}
|
||||
}
|
||||
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset !== undefined) {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs !== undefined) {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs.config.value !== undefined) {
|
||||
ecpochs = learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs.config.value
|
||||
}
|
||||
}
|
||||
let initialCandle = Math.trunc(sessionParameters.timeRange.config.initialDatetime / sessionParameters.timeFrame.config.value)
|
||||
let finalCandle = Math.trunc(sessionParameters.timeRange.config.finalDatetime / sessionParameters.timeFrame.config.value)
|
||||
let currentCandle = Math.trunc(learningEngine.learningCurrent.learningEpisode.candle.begin.value / sessionParameters.timeFrame.config.value)
|
||||
let thresholdCandle = (finalCandle - initialCandle) * backLearningPredictingRatio + initialCandle
|
||||
|
||||
if (currentCandle < thresholdCandle) {
|
||||
await learn()
|
||||
} else {
|
||||
predict()
|
||||
}
|
||||
|
||||
await tensorFlowModel.fitDataset(ds, {
|
||||
verbose: verbose,
|
||||
epochs: ecpochs
|
||||
})
|
||||
async function learn() {
|
||||
/*
|
||||
Building the Labels Tensor
|
||||
*/
|
||||
if (layersModel.outputLayer === undefined) {
|
||||
// TODO
|
||||
}
|
||||
if (layersModel.outputLayer.outputLabels === undefined) {
|
||||
// TODO
|
||||
}
|
||||
learningSystem.evalFormulas(layersModel.outputLayer.outputLabels, layersModel.outputLayer.outputLabels.type)
|
||||
|
||||
//tensorFlowModel.summary()
|
||||
for (let i = 0; i < layersModel.outputLayer.outputLabels.dataLabels.length; i++) {
|
||||
let dataLabel = layersModel.outputLayer.outputLabels.dataLabels[i]
|
||||
if (dataLabel.labelFormula === undefined) { continue }
|
||||
let labelValue = learningSystem.formulas.get(dataLabel.labelFormula.id)
|
||||
labels.push(labelValue)
|
||||
}
|
||||
|
||||
tensorFlowData = require("@tensorflow/tfjs-data")
|
||||
|
||||
function* featuresGenerator() {
|
||||
//console.log('Features: ' + features)
|
||||
yield features
|
||||
}
|
||||
|
||||
function* labelsGenerator() {
|
||||
//console.log('Labels: ' + labels)
|
||||
yield labels
|
||||
}
|
||||
|
||||
const xs = tensorFlowData.generator(featuresGenerator)
|
||||
const ys = tensorFlowData.generator(labelsGenerator)
|
||||
const ds = tensorFlowData.zip({ xs, ys }).shuffle(1).batch(1)
|
||||
|
||||
let verbose = 0
|
||||
let ecpochs = 1
|
||||
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset !== undefined) {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose !== undefined) {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose.config.value !== undefined) {
|
||||
verbose = learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.verbose.config.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset !== undefined) {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs !== undefined) {
|
||||
if (learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs.config.value !== undefined) {
|
||||
ecpochs = learningSystem.machineLearningLibrary.typeOfLearning.typeOfModel.model.fitDataset.epochs.config.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await tensorFlowModel.fitDataset(ds, {
|
||||
verbose: verbose,
|
||||
epochs: ecpochs
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async function predict() {
|
||||
let featuresTensor = tensorFlowBackend.tensor([features])
|
||||
let predictions = tensorFlowModel.predict(featuresTensor,{ verbose: 1 })
|
||||
|
||||
/*
|
||||
For each label, we will have a predictions, and we will store it at the
|
||||
learning engine data structure.
|
||||
*/
|
||||
let predictionsArray = predictions.dataSync()
|
||||
predictions.dispose()
|
||||
featuresTensor.dispose()
|
||||
|
||||
for (let i = 0; i < predictionsArray.length; i++) {
|
||||
let prediction = predictionsArray[i]
|
||||
learningEngine.predictions.predictions[i].value = prediction
|
||||
learningEngine.predictions.predictions[i].begin.value = learningEngine.learningCurrent.learningEpisode.candle.begin.value
|
||||
learningEngine.predictions.predictions[i].end.value = learningEngine.learningCurrent.learningEpisode.candle.end.value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function badDefinitionUnhandledException(err, message, node) {
|
||||
|
||||
Reference in new issue
Block a user