# Using TensorFlow.js and p5js to fit a curve to a synthetic dataset

**URL:** https://discourse.processing.org/t/using-tensorflow-js-and-p5js-to-fit-a-curve-to-a-synthetic-dataset/3878
**Category:** Gallery
**Created:** [September 26, 2018, 7:43pm UTC](https://discourse.processing.org/t/using-tensorflow-js-and-p5js-to-fit-a-curve-to-a-synthetic-dataset/3878 "2018-09-26T19:43:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![atoro](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/atoro/32/1351_2.png) [@atoro](https://discourse.processing.org/u/atoro)
#### Post date: [September 26, 2018, 7:43pm UTC](https://discourse.processing.org/t/using-tensorflow-js-and-p5js-to-fit-a-curve-to-a-synthetic-dataset/3878/1 "2018-09-26T19:43:52Z")

</div>

![05](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/93697ac1d8f0401f34b0633dc4695f0c79e41be1.png)

* * *

[Click here to see a short demo animation (as an animated GIF)](https://github.com/atorov/ml-tfjs-fitting-curve/blob/master/assets/demo.gif)

This example uses TensorFlow.js to build a model and learn its coefficients. The basic idea is very similar to the tutorial `Fitting a Curve to Synthetic Data` which is a part of the official TFJS documentation but this specific implementation is different in many aspects.

To run the code locally, you need the following dependencies installed:

- Node.js version 8.9 or higher
- NPM CLI

```auto
$ git clone https://github.com/atorov/ml-tfjs-fitting-curve
$ cd ml-tfjs-fitting-curve
$ npm i
$ npm start

```

The code is available here: [https://github.com/atorov/ml-tfjs-fitting-curve](https://github.com/atorov/ml-tfjs-fitting-curve)
