{"id":5060,"date":"2024-02-15T17:01:27","date_gmt":"2024-02-15T17:01:27","guid":{"rendered":"https:\/\/dalelane.co.uk\/blog\/?p=5060"},"modified":"2026-04-02T18:26:33","modified_gmt":"2026-04-02T18:26:33","slug":"explaining-regression-in-scratch","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=5060","title":{"rendered":"Explaining regression in Scratch"},"content":{"rendered":"<p><strong>In this post, I want to share a preview of a new feature I&#8217;m adding to <a href=\"https:\/\/machinelearningforkids.co.uk\">Machine Learning for Kids<\/a>, to ask for feedback and ideas for projects that it could be used to make.<\/strong><\/p>\n<p>I&#8217;ll start by contrasting this new feature with what I&#8217;ve done with <a href=\"https:\/\/machinelearningforkids.co.uk\">Machine Learning for Kids<\/a> before, then I&#8217;ll share screenshots of the new feature, and finally I&#8217;ve got a ten-minute video showing the sort of school lesson that I think it could be used for.<\/p>\n<p><!--more--><\/p>\n<h3>Machine Learning for Kids so far<\/h3>\n<p>Until now, most of the machine learning models I&#8217;ve enabled in <a href=\"https:\/\/machinelearningforkids.co.uk\">Machine Learning for Kids<\/a> have been classification models. <\/p>\n<p>Students collect examples of different types of things, and create a machine learning model that can recognize what type a new thing is. <\/p>\n<p>Classifiers are simple to explain, easy to train, and enable a variety of interesting projects. <\/p>\n<p>Collect examples of headlines from different newspapers. Give the model a new headline, and it can recognize which newspaper the headline is from.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.dalelane.co.uk\/2024-02-15-mlforkids\/headlines-data.png\"\/> <img decoding=\"async\" style=\"border: thin black solid;\"  src=\"https:\/\/github.com\/IBM\/taxinomitis\/blob\/master\/mlforkids-api\/public\/images\/full-size\/project-headlines-easy.png?raw=true\"\/><\/p>\n<p>Collect examples of statistics of Pokemon of different types. Give the model the stats for a new Pokemon, and it can recognize what type the Pokemon is.<\/p>\n<p><img decoding=\"async\" style=\"border: thin black solid;\" src=\"https:\/\/images.dalelane.co.uk\/2024-02-15-mlforkids\/pokemon-data.png\"\/> <img decoding=\"async\" style=\"border: thin black solid;\" src=\"https:\/\/github.com\/IBM\/taxinomitis\/blob\/master\/mlforkids-api\/public\/images\/full-size\/project-pokemonstatistics.png?raw=true\"\/><\/p>\n<p>Collect examples of pictures from a traffic camera, sorted into the number of passengers that can be seen. Give the model a picture of a new car, and it can recognize whether the car belongs in the car pool lane.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.dalelane.co.uk\/2024-02-15-mlforkids\/carpool-data.png\" style=\"border: thin black solid;\"\/> <img decoding=\"async\" src=\"https:\/\/github.com\/IBM\/taxinomitis\/blob\/master\/mlforkids-api\/public\/images\/full-size\/project-carpoolcheats.png?raw=true\" style=\"border: thin black solid;\"\/><\/p>\n<p>Collect examples of recordings of different types of sounds, sorted into different commands. Give the model a new sound recording, and it can recognize which command it has heard.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.dalelane.co.uk\/2024-02-15-mlforkids\/secretcode-data.png\" style=\"border: thin black solid;\"\/> <img decoding=\"async\" src=\"https:\/\/github.com\/IBM\/taxinomitis\/blob\/master\/mlforkids-api\/public\/images\/full-size\/project-secretcode.png?raw=true\" style=\"border: thin black solid;\"\/><\/p>\n<p>Classification models.<\/p>\n<p>I&#8217;ve seen hundreds of projects created using this simple pattern. The input is collection of things, sorted into buckets. The output is the name of the bucket that a new thing should go into.<\/p>\n<h3>Regression models can enable different project types<\/h3>\n<p>With regression models, you still collect training examples, but instead of sorting them into groups, each examples has one or more numerical output values.<\/p>\n<p>When you give the model a new example, instead of recognizing what bucket it should go into, the model predicts what the output value(s) should be.<\/p>\n<h3>Example of a regression project<\/h3>\n<p>My first test\/demo of the regression model support in action is predicting where a bouncing ball will first hit the ground. The training examples are the starting location, speed, and direction. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.dalelane.co.uk\/2024-02-15-mlforkids\/regression-data.png\" style=\"border: thin black solid;\"\/><\/p>\n<p>The model predicts the x coordinate for where the ball will first hit the ground &#8211; so you can use that to try and catch the ball before it hits the ground.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images.dalelane.co.uk\/2024-02-15-mlforkids\/regression-test.png\" style=\"border: thin black solid;\"\/><\/p>\n<p>This is a nice example of the sort of project that you couldn\u2019t create using classification models, so I think it\u2019s a nice extension to Machine Learning for Kids.<\/p>\n<h3>Demo of the new feature in action<\/h3>\n<p><iframe loading=\"lazy\" width=\"450\" height=\"270\" style=\"border: thin black solid;\" src=\"https:\/\/www.youtube.com\/embed\/SiUURaOQcdk?si=W_UogqDeA2yHgFDU\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><br \/>\n<small><a href=\"https:\/\/youtu.be\/SiUURaOQcdk\">youtu.be\/SiUURaOQcdk<\/a><\/small><\/p>\n<p>Here is a ten-minute run-through of what a regression lesson could look like, using the bouncing ball project idea. <\/p>\n<p>What do you think? <\/p>\n<p>Can you think of any other project ideas that regression models could enable? <\/p>\n<p>Can you think of a better way to present or explain it to children?<\/p>\n<p>Please <a href=\"https:\/\/dalelane.co.uk\">let me know<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, I want to share a preview of a new feature I&#8217;m adding to Machine Learning for Kids, to ask for feedback and ideas for projects that it could be used to make. I&#8217;ll start by contrasting this new feature with what I&#8217;ve done with Machine Learning for Kids before, then I&#8217;ll share [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5067,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[587],"class_list":["post-5060","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code","tag-mlforkids-tech"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5060","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5060"}],"version-history":[{"count":2,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5060\/revisions"}],"predecessor-version":[{"id":5968,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5060\/revisions\/5968"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/media\/5067"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5060"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5060"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5060"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}