{"id":13672937,"url":"https://github.com/laoqiren/mlhelper","last_synced_at":"2025-04-28T04:30:40.228Z","repository":{"id":80879939,"uuid":"106424320","full_name":"laoqiren/mlhelper","owner":"laoqiren","description":"Algorithms and utils for Machine Learning in JavaScript.","archived":false,"fork":false,"pushed_at":"2019-04-01T09:33:32.000Z","size":2634,"stargazers_count":638,"open_issues_count":2,"forks_count":36,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-08-03T09:13:20.764Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laoqiren.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-10-10T13:55:54.000Z","updated_at":"2024-04-28T21:56:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"cba27eec-bfdd-497a-bc1d-b534b84d44cf","html_url":"https://github.com/laoqiren/mlhelper","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laoqiren%2Fmlhelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laoqiren%2Fmlhelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laoqiren%2Fmlhelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laoqiren%2Fmlhelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laoqiren","download_url":"https://codeload.github.com/laoqiren/mlhelper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224095145,"owners_count":17254837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T09:01:58.747Z","updated_at":"2024-11-11T11:30:34.336Z","avatar_url":"https://github.com/laoqiren.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# mlhelper\n[![npm](https://img.shields.io/npm/v/mlhelper.svg?style=flat-square)](https://github.com/laoqiren/mlhelper)\n[![npm](https://img.shields.io/npm/l/mlhelper.svg?style=flat-square)](https://github.com/laoqiren/mlhelper)\n\nAlgorithms and utils for Machine Learning in JavaScript based on Node.js. while implementing commonly used machine learning algorithms, This library attempts to provide more abundant ecology, such as matrix and vector operations, file parsing, feature engineering, data visualization, and so on.\n\n*`QQ Group`: 485305514*\n## Installation\n```\n$ npm install mlhelper\n```\n\n## Documention\n\n* [algorithm](docs/algorithm.md)\n* [Matrix](docs/Matrix.md)\n* [Vector](docs/Vector.md)\n* [file Parser](docs/fileParser.md)\n* [graph tools](docs/graph.md)\n* [feature Engineering](docs/features.md)\n\n## Example\n\n### Algorithm\n\n```js\nconst AdaBoost = require('mlhelper/lib/algorithm').AdaBoost;\n//or const AdaBoost = require('mlhelper').algorithm.AdaBoost;\n\nconst dataSet = [\n    [1.0,2.1],\n    [2.0,1.1],\n    [1.3,1.0],\n    [1.0,1.0],\n    [2.0,1.0]\n]\nconst labels = [1.0,1.0,-1.0,-1.0,1.0];\nlet ada = new AdaBoost(dataSet,labels,40);\nlet result = ada.classify([[1.0,2.1],\n    [2.0,1.1],\n    [1.3,1.0],\n    [1.0,1.0],\n    [2.0,1.0]]);\nconsole.log(result); // [ 1, 1, -1, -1, -1 ]\n```\n\n### Utils\n\n**Matrix:**\n```js\nconst Matrix = require('mlhelper/lib/utils').Matrix;\n\nlet m1 = new Matrix([\n    [1,2,3],\n    [3,4,5]\n]);\n\nlet m2 = new Matrix([\n    [2,2,6],\n    [3,1,5]\n]);\n\nconsole.log(m2.sub(m1)) // Matrix { arr: [ [ 1, 0, 3 ], [ 0, -3, 0 ] ] }\nconsole.log(m1.mult(m2)) // Matrix { arr: [ [ 2, 4, 18 ], [ 9, 4, 25 ] ] }\n```\n\n**Vector:**\n```js\nconst Vector = require('mlhelper/lib/utils').Vector;\n\nlet v = new Vector([5,10,7,1]);\nconsole.log(v.argSort()) // [ 3, 0, 2, 1 ]\n```\n\n**fileParser:**\n```js\nconst parser = require('mlhelper/lib/utils').fileParser;\n\nlet dt = parser.read_csv(path.join(__dirname,'./train.csv'),{\n    index_col: 0,\n    delimiter: ',',\n    header: 0,\n    dataType: 'number'\n});\nlet labels = dt.getClasses();\nlet dataSet =dt.drop('quality').values;\n```\n\n**Feature Engineering**\n```js\n// preprocessing features\nconst preprocessing = require('mlhelper/lib/utils').features.preprocessing;\n\n// make the features obey the standard normal distribution(Standardization)\nlet testStandardScaler = preprocessing.standardScaler(dataSet);\n\nlet testNormalize = preprocessing.normalize(dataSet);\n\nlet testBinarizer = preprocessing.binarizer(dataSet);\n\n// ...\n```\n\n**graph tools:**\n\nDecision Tree:\n```js\ncharts.drawDT(dt.getTree(),{\n    width:600,\n    height:400\n});\n```\n![/assets/DT.png](/assets/DT.png)\n\n**logistic regression**\n```js\ncharts.drawLogistic(dataSet,labels,weights);\n```\n\u003cimg src=\"/assets/logistic2.png\" width=\"550px\"/\u003e\n\n\n## Contribute\n\nThe original purpose of this project is to learn, and now I need more people to participate in this project, and any issue and good advice is welcome.\n### git clone \n```\ngit clone https://github.com/laoqiren/mlhelper.git\n```\n### install dependencies\u0026\u0026devdependecies\n```\nnpm install\n```\n\n### development\n```\nnpm run dev\n```\n\n### test\n```\nnpm run test\n```\n\n### build\n```\nnpm run build\n```\n## LICENSE\nMIT.\n\n*You can use the project for any purpose, except for illegal activities.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaoqiren%2Fmlhelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaoqiren%2Fmlhelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaoqiren%2Fmlhelper/lists"}