diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a382f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.node_modules +/node_modules +.codegpt \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..f73291b --- /dev/null +++ b/index.js @@ -0,0 +1,159 @@ +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= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/regression": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regression/-/regression-2.0.1.tgz", + "integrity": "sha512-A4XYsc37dsBaNOgEjkJKzfJlE394IMmUPlI/p3TTI9u3T+2a+eox5Pr/CPUqF0eszeWZJPAc6QkroAhuUpWDJQ==", + "license": "MIT" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..c8b8026 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "1-nemoodar", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "axios": "^1.7.9", + "regression": "^2.0.1" + } +}