const regression = require('regression'); // const readline = require('node:readline'); // const rl = readline.createInterface({ // input: process.stdin, // output: process.stdout // }) const data = [ [6,88], [10,71], [5,19], [9,59], [8,18], [3,77], [2,61], [1,53], [7,13], [4,40], ] class Nemoodar{ data; first_length=0; algorithms={ "linear":{ data:[], enheraf:0, }, "exponential":{ data:[], enheraf:0, }, "power":{ data:[], enheraf:0, }, "logarithmic":{ data:[], enheraf:0, }, "polynomial2":{ data:[], enheraf:0, }, "polynomial3":{ data:[], enheraf:0, }, "polynomial4":{ data:[], enheraf:0, },"polynomial5":{ data:[], enheraf:0, } } constructor({data,predict=1,option="linear",n=2}){ console.log("option",option) this.data = [...data.sort((a,b)=> a[0] - b[0])]; this.first_length = this.data.length; for(let algo in this.algorithms){ switch(algo){ case "linear": this.algorithms[algo].data=this.linear([...data],predict); break; case "exponential": this.algorithms[algo].data=this.exponential([...data],predict) break; case "power": this.algorithms[algo].data=this.power([...data],predict) break; case "logarithmic": this.algorithms[algo].data=this.logarithmic([...data],predict) break; case "polynomial2": this.algorithms[algo].data=this.polynomial([...data],predict,2); break; case "polynomial3": this.algorithms[algo].data=this.polynomial([...data],predict,3); break; case "polynomial4": this.algorithms[algo].data=this.polynomial([...data],predict,4); break; case "polynomial5": this.algorithms[algo].data=this.polynomial([...data],predict,5); break; } } for(let algo in this.algorithms){ const theData = this.algorithms[algo].data; let sum = 0; for(let i=0;i5) n=5; const result = regression.polynomial(data,{order: n}); return this.predict(result,predict) } predict(rgr,predict){ console.log(rgr.string); const newData = [] for(let i=0;i