{"id":13548316,"url":"https://github.com/luccastera/shaman","last_synced_at":"2026-01-16T06:55:26.921Z","repository":{"id":57144531,"uuid":"25437887","full_name":"luccastera/shaman","owner":"luccastera","description":"Machine Learning library for node.js","archived":false,"fork":false,"pushed_at":"2016-02-04T16:50:05.000Z","size":340,"stargazers_count":109,"open_issues_count":0,"forks_count":11,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T05:52:19.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/luccastera.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-19T19:39:06.000Z","updated_at":"2024-10-09T10:11:32.000Z","dependencies_parsed_at":"2022-09-05T08:50:37.776Z","dependency_job_id":null,"html_url":"https://github.com/luccastera/shaman","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccastera%2Fshaman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccastera%2Fshaman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccastera%2Fshaman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccastera%2Fshaman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luccastera","download_url":"https://codeload.github.com/luccastera/shaman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246895718,"owners_count":20851320,"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-01T12:01:08.724Z","updated_at":"2026-01-16T06:55:26.870Z","avatar_url":"https://github.com/luccastera.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Javascript"],"sub_categories":["Tools","[Tools](#tools-1)","Speech Recognition"],"readme":"# shaman\n\nMachine Learning library for node.js\n\n## Linear Regression\n\nshaman supports [both simple linear regression  and multiple linear\nregression](http://en.wikipedia.org/wiki/Linear_regression#Simple_and_multiple_regression).\n\nIt supports two different algorithms to train the model:\n\n0. [The Normal Equation](http://en.wikipedia.org/wiki/Linear_least_squares_(mathematics))\n1. [The Gradient Descent Algorithm](http://en.wikipedia.org/wiki/Gradient_descent)\n\n### Usage\n\nBy default, shaman uses the Normal Equation for linear regression.\n\n```javascript\nvar X = [1, 2, 3, 4, 5];\nvar Y = [2, 2, 3, 3, 5];\nvar lr = new LinearRegression(X,Y);\nlr.train(function(err) {\n  if (err) { throw err; }\n  \n  // you can now start using lr.predict:\n  console.log(lr.predict(1));\n});\n```\n\nIf your data does not work well with the Normal Equation, you can also\nuse the Gradient Descent algorithm as an alternative.\n\n```javascript\nvar X = [1, 2, 3, 4, 5];\nvar Y = [2, 2, 3, 3, 5];\nvar lr = new LinearRegression(X,Y, {\n  algorithm: 'GradientDescent'\n});\nlr.train(function(err) {\n  if (err) { throw err; }\n  \n  // you can now start using lr.predict:\n  console.log(lr.predict(1));\n});\n```\n\nWhen using Gradient Descent, you can define the number of iterations\n(numberOfIterations and the learning rate (learningRate) as options to\nthe LinearRegression function.\n\n\n```javascript\nvar lr = new LinearRegression(X,Y, {\n  algorithm: 'GradientDescent',\n  numberOfIterations: 1000, // defaults to 8500\n  learningRate: 0.5 // defaults to 0.1\n});\n```\n\nWhen using the Gradient Descent algorithm, you can ask shaman to save\nthe results of the cost function at each iteration of the algorithm.\nThis can be useful if you would like to plot the cost function to ensure\nthat it is converging.\n\n```javascript\nvar lr = new LinearRegression(X,Y, {\n  algorithm: 'GradientDescent',\n  saveCosts: true // defaults to false\n});\nlr.train(function(err) {\n  // you can now get they array of costs:\n  console.log(lr.costs);\n});\n```\n\nIf you are troubleshooting, you can pass in a debug option (set to\ntrue). Shaman will then debug useful info in the console (such as the\ncost at every iteration of the Gradient Descent algorithem).\n\n```javascript\nvar lr = new LinearRegression(X,Y, {\n  algorithm: 'GradientDescent',\n  debug: true // defaults to false\n});\nlr.train(function(err) {\n  // will console.log some useful info\n});\n```\n\n### Examples\n\n\n#### Simple Linear Regression - Cars\n\n[Below](https://plot.ly/~luccastera/2) to see an example of Simple Linear Regression\nusing the Normal Equation to evaluate the price of cars based on their horsepower that was done with the shaman\nlibrary. Code is in [examples/cars.js](examples/cars.js)).\n\n![Cars Example](examples/cars.png)\n\n#### Simple Linear Regression - AAPL Stock Price\n\n[Below](https://plot.ly/~luccastera/3/aapl-stock-prices/) to see an\nexample of Simple Linear Regression applies to the stock price of AAPL\nusing the Gradient Descent algorithm from 2008 to 2012. Code can be seen at\n[examples/stock.js](examples/stock.js).\n\n![Stock Example](examples/stock.png)\n\n#### Multiple Linear Regression - Cigarettes\n\n[Below](https://plot.ly/~luccastera/4/cigarettes/) to see an\nexample of Multiple Linear Regression to evaluate Carbon Monoxide in\ncigarettes from nicotine and tar content. Code can be seen at\n[examples/cigarettes.js](examples/cigarettes.js).\n\n![Cigarettes Example](examples/cigarettes.png)\n\n## Clustering (k-means)\n\nshaman implements the k-means clustering algorithm.\n\n### Usage\n\n```javascript\nvar KMeans = require('shaman').KMeans;\n\nvar K = 4;\nvar kmeans = new KMeans(K);\n\nkmeans.cluster(data, function(err, clusters, centroids) {\n  if (err) { throw err; }\n\n  console.log(clusters);\n});\n\n```\n\n### Example: clustering wines\n\n[Below](https://plot.ly/~luccastera/20/wine/) to see an example of\nclustering using the k-means algorithm on [the wine dataset from\nUCI](http://archive.ics.uci.edu/ml/datasets/Wine).\n\nThe code is located at [examples/wine.js](examples/wine.js).\n\n![Wine Example](examples/wine.png)\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluccastera%2Fshaman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluccastera%2Fshaman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluccastera%2Fshaman/lists"}