{"id":21448175,"url":"https://github.com/ehsangazar/linear-machine-learning-project","last_synced_at":"2025-03-17T02:09:47.975Z","repository":{"id":124407183,"uuid":"135235264","full_name":"ehsangazar/linear-machine-learning-project","owner":"ehsangazar","description":"Linear Machine Learning Project using Tensorflow and React","archived":false,"fork":false,"pushed_at":"2018-05-29T03:40:30.000Z","size":1245,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T11:45:47.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://ehsangazar.com/linear-machine-learning-and-tensorflowjs-5e212b8a318d","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehsangazar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-29T03:13:01.000Z","updated_at":"2018-08-22T11:17:03.000Z","dependencies_parsed_at":"2023-07-23T06:31:55.176Z","dependency_job_id":null,"html_url":"https://github.com/ehsangazar/linear-machine-learning-project","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/ehsangazar%2Flinear-machine-learning-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsangazar%2Flinear-machine-learning-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsangazar%2Flinear-machine-learning-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehsangazar%2Flinear-machine-learning-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehsangazar","download_url":"https://codeload.github.com/ehsangazar/linear-machine-learning-project/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960666,"owners_count":20375104,"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-11-23T03:14:22.690Z","updated_at":"2025-03-17T02:09:47.969Z","avatar_url":"https://github.com/ehsangazar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linear machine learning project\n\nI have started learning machine learning and this is the basic of tensorflow.js and linear learning algorithm\n\nDemo: https://ehsangazar.github.io/linear-machine-learning-project/\n\n\n## Importing tensorflow\n\n```\nimport * as tf from '@tensorflow/tfjs';\n```\n\n## Initializing the Model\n- Sequential because it will be a sequence of numbers\n- dense layers are fully connected layers\n- units is dimensionality of the output space\n- inputShape will be used to create an input layer to insert before this layer\n- sgd: Stochastic gradient descent\nhttps://en.wikipedia.org/wiki/Stochastic_gradient_descent\n- meanSquaredError: this is our loss definition\n\n```\nthis.linearModel = tf.sequential();\n  // linear\n  this.linearModel.add(tf.layers.dense({\n    units: 1,\n    inputShape: [1]\n  }))\n\n  // preate the model for training with defnining Loss function\n  this.linearModel.compile({\n    optimizer: 'sgd',\n    loss: 'meanSquaredError'\n  });\n```\n\n## Training with Data\n\nTwo arrays for using as a training data\n```\nconst xs = tf.tensor1d([1.2, 2.4, 3.5, 4.71, 5.98, 6.168, 7.779, 8.182, 9.59, 2.16, 7.042, 10.71, 5.313, 7.97, 5.654, 9.7, 3.11]);\n\nconst ys = tf.tensor1d([4.6, 5.7, 6.9, 9.19, 10.684, 12.53, 23.366, 32.596, 42.53, 1.22, 2.87, 3.45, 1.65, 2.904, 2.42, 2.4, 1.31]);\n\nthis.linearModel.fit(xs, ys)\n```\n\n\n## Prediction for the next number\nThis will predict a number based on a value\n\n```\nthis.linearModel.predict(tf.tensor2d([value], [1, 1]))\n```\n\n\nIf you want, create a pull-request or just contact me on @ehsangazar","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsangazar%2Flinear-machine-learning-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehsangazar%2Flinear-machine-learning-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehsangazar%2Flinear-machine-learning-project/lists"}