exporttest3.txt (2.5 MB)
Hi there,
I am trying to use the node-red-contribution-regression node.
My x values are date time coming from a flow.
In which format should I feed the data/time to the regression node?
At present my date time format is 2021-09-24 18:01:04.919
But if I use it in such format, I keep getting y=0x+27.89
I noted that passing only the time (18:01:04.919) the regression node is working but since my data includes also year-month-day, I need to pass also this part. At least month-day in addition to the time.
Another unexpected thing I am experiencing is that such node will start outputting NaN values for Y as soon as a couple of hundred values are computed and the formula starts compiling. I have 36000 points to evaluate. I did try to set the data set size to 36000 but the behaviour doesn't change.
Any hint?
[
{
"id": "d3941b648342c52c",
"type": "inject",
"z": "2b15a36f0d2c0957",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 280,
"y": 200,
"wires": [
[
"7b997a168c5e6c62"
]
]
},
{
"id": "7b997a168c5e6c62",
"type": "file in",
"z": "2b15a36f0d2c0957",
"name": "",
"filename": "/Users/felicemassaro/Downloads/exporttest3.txt",
"format": "lines",
"chunk": false,
"sendError": false,
"encoding": "utf8",
"allProps": false,
"x": 580,
"y": 200,
"wires": [
[
"00e59343511ae655"
]
]
},
{
"id": "db9f3a750ab25d30",
"type": "function",
"z": "2b15a36f0d2c0957",
"name": "Unpack voltage",
"func": "var output= msg.payload.split(\",\");\nvar voltage=parseFloat(output[2]).toFixed(3);\nvar msg3={payload : voltage};\n\n\n\nreturn msg3;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 280,
"wires": [
[
"36951e3318a37c7f"
]
]
},
{
"id": "36951e3318a37c7f",
"type": "change",
"z": "2b15a36f0d2c0957",
"name": "",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "voltage",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 280,
"wires": [
[
"f478dc20e8fbe695"
]
]
},
{
"id": "cd5274eb82f2c104",
"type": "link out",
"z": "2b15a36f0d2c0957",
"name": "",
"mode": "link",
"links": [
"3c86964fec64c7e3",
"830d288b2f7bebe7",
"77731fbfda666688"
],
"x": 975,
"y": 200,
"wires": []
},
{
"id": "3c86964fec64c7e3",
"type": "link in",
"z": "2b15a36f0d2c0957",
"name": "",
"links": [
"cd5274eb82f2c104"
],
"x": 235,
"y": 280,
"wires": [
[
"db9f3a750ab25d30"
]
]
},
{
"id": "41a80d8331729fb4",
"type": "function",
"z": "2b15a36f0d2c0957",
"name": "Unpack time",
"func": "var output= msg.payload.split(\",\");\nvar time=(output[1]);\nvar msg2={payload : time};\nreturn msg2;\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 360,
"wires": [
[
"032e8dd084339dad"
]
]
},
{
"id": "77731fbfda666688",
"type": "link in",
"z": "2b15a36f0d2c0957",
"name": "",
"links": [
"cd5274eb82f2c104"
],
"x": 235,
"y": 360,
"wires": [
[
"41a80d8331729fb4"
]
]
},
{
"id": "032e8dd084339dad",
"type": "change",
"z": "2b15a36f0d2c0957",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "$moment(payload).format('HH:mm:ss.SSS')",
"tot": "jsonata"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "time",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 520,
"y": 360,
"wires": [
[
"f478dc20e8fbe695"
]
]
},
{
"id": "00a67fe38392dfc2",
"type": "regression",
"z": "2b15a36f0d2c0957",
"name": "",
"dataSetSize": "0",
"regressionType": "polynomial",
"polynomialOrder": "2",
"precision": "4",
"xInputField": "payload.x",
"xInputFieldType": "msg",
"yInputField": "payload.y",
"yInputFieldType": "msg",
"yOutputField": "payload.y",
"yOutputFieldType": "msg",
"functionOutputField": "P",
"functionOutputFieldType": "msg",
"resultOnly": false,
"x": 1070,
"y": 320,
"wires": [
[
"40096f992a4d8439"
]
]
},
{
"id": "40096f992a4d8439",
"type": "debug",
"z": "2b15a36f0d2c0957",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1250,
"y": 320,
"wires": []
},
{
"id": "f478dc20e8fbe695",
"type": "join",
"z": "2b15a36f0d2c0957",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "2",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 710,
"y": 320,
"wires": [
[
"33ece8d92bd59b5e"
]
]
},
{
"id": "33ece8d92bd59b5e",
"type": "function",
"z": "2b15a36f0d2c0957",
"name": "sample formatting",
"func": "msg.payload = {x: msg.payload.time, y: msg.payload.voltage}\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 870,
"y": 320,
"wires": [
[
"00a67fe38392dfc2"
]
]
},
{
"id": "250f1e1742af6cce",
"type": "change",
"z": "2b15a36f0d2c0957",
"name": "",
"rules": [
{
"t": "set",
"p": "reset",
"pt": "msg",
"to": "1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 620,
"y": 100,
"wires": [
[
"00e59343511ae655"
]
]
},
{
"id": "f9f07b83b576dbc9",
"type": "inject",
"z": "2b15a36f0d2c0957",
"name": "Reset",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payloadType": "date",
"x": 410,
"y": 100,
"wires": [
[
"250f1e1742af6cce"
]
]
},
{
"id": "00e59343511ae655",
"type": "delay",
"z": "2b15a36f0d2c0957",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "20",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 860,
"y": 200,
"wires": [
[
"cd5274eb82f2c104"
]
]
}
]