Coding Challenge #105: Polynomial Regression with TensorFlow.js

[ad_1]
In this challenge, I expand the linear example ( into polynomial regression!

🔗 TensorFlow.js:

🎥 Linear Regression:
🎥 More TensorFlow.js:

🚂 Website:
💖 Patreon:
Store:
📚 Book recommendations:

💻

🎥 For More Intelligence and Learning videos:
🎥 For More Coding Challenges:

🔗
🔗


Posted

in

by

Tags:

Comments

12 responses to “Coding Challenge #105: Polynomial Regression with TensorFlow.js”

  1. kustomweb Avatar

    It's starting to look like magic. The black box aspect of this most impressive demonstration is worrisome. It works, but you don't know how. It can tell you the difference between a cat and a dog, but not how it figured it out. This is where ethics become so important, because if I'm rejected for a loan by an AI, I'm going to want a reason, not just a result.

  2. Lev Mizgirev Avatar

    Dan, thanks for this amazing tutorial. I was actually thinking to implement it myself and you noticed my comment asking about it in the chat. Cool, at least now I know how to do it.

  3. Ken Haley Avatar

    First of all, I absolutely love this series on tensorflow.js! Great job! I am learning a lot — I doubt if I would ever have delved into this topic without your hands-on demos.

    Anyway, having worked with programs that evalutate polynomials in the past, I thought I'd make a suggestion for efficiency and (IMHO) elegance:
    Notice that:
    ax^2 + bx + c can be written as ((ax + b)x + c — saving one multiply operation.
    and..
    ax^3 + bx^2 + cx + d can be written as (((ax + b)x + c)x + d – saving 3 multiply operations (if you count cubing as 2 multiply's).
    The higher the degree, the more multiply operations you save.

    But even better, look at how easy it is to add a degree to the polynomial. Just multiply the previous expression by x and add the next coefficient. And now there's no need to call the square function, etc.
    So, your predict code for one degree would be
    const ys = a.mul(xs).add(b) (I'm using a instead of m here, to demo the symmetry that follows)
    For 2nd degree (quadratic) it's
    const ys = a.mul(xs).add(b).mul(xs).add(c)
    For 3rd degree (cubic) it's
    const ys = a.mul(xs).add(b).mul(xs).add(c).mul(xs).add(d)
    Notice that there's only one level of parentheses making it easy to understand, and for each degree you just append a multiply and add operation.
    Whaddya think?

  4. GABRIELFILMSTUDIOS Avatar

    Dan, if you look for a good resource for algebra, there is 3blue1brown‘s series.

  5. ew cringe Avatar

    I learn more here than my actual coding class

  6. BinaryReader Avatar

    Really awesome video Dan, more videos on TF is you can, its really a superb resource for programmers looking to understand tensorflow and what it can do. 10/10.

  7. Mikee Avatar

    That intro at 1:42 just made my day

  8. Amish Sharma Avatar

    Unfortunately, I only know c/c++. Where can I learn javascript, to start game development??

  9. anirudh bhardwaj Avatar

    helllo! i have a question. how do you make something happen by clicking on a specific object like a rectangle?

  10. Rage Avatar

    I am actually first! Nice video Dan as always! Keep it up I really like your videos, because i learn a lot from them!

Leave a Reply

Your email address will not be published. Required fields are marked *