Why are the model test results inconsistent with the results when calling the model in the Scratch program?

33 views
Skip to first unread message

chen liao

unread,
Apr 16, 2026, 6:55:01 AM (7 days ago) Apr 16
to Machine Learning for Kids
Hi, I wrote a handwritten digit recognition program, and the model performed well in testing. However, when using Scratch to call "recognise image" for recognition, the accuracy is very low, and the digit 1 is often misrecognized as other digits. What could be the reason?
Thank you very much!
Best regards !
WXWorkLocal_17763365108468.pngWXWorkLocal_17763366246501.png

Dale Lane

unread,
Apr 16, 2026, 6:57:40 AM (7 days ago) Apr 16
to Machine Learning for Kids
I don't think it should be inconsistent - but it's difficult to explain why you're getting the results you're getting without seeing your Scratch code (the screenshot just shows you displaying a Scratch variable, but not how that variable was set)

Would you mind showing a little more?

including:
* what data you are using? (e.g. is it a costume? or a backdrop? what image are you using to test inside Scratch? can you share a copy?)
* what code are you using? 

Kind regards

D

chen liao

unread,
Apr 17, 2026, 7:47:02 AM (6 days ago) Apr 17
to Machine Learning for Kids
Dear Dale Lane:
      Thank you for your reply. This Scratch program is very simple. First, a hand-drawn costume is created, and a variable named number is made based on that costume. Then the number 1 is drawn by hand. Next, a number recognition model is called to identify the hand-drawn costume, and the recognition result is set as the value of the variable number. Finally, the initial costume is used to say the value of the variable. The code is shown in the picture.  
        Best wishes for you !1.jpg2.jpg
        Chen 

Dale Lane

unread,
Apr 17, 2026, 7:47:51 AM (6 days ago) Apr 17
to Machine Learning for Kids
Would you mind sharing what the costume is please? 

For example, from the thumbnail, it looks like it has a transparent background - is that right? 

Kind regards

D

chen liao

unread,
Apr 19, 2026, 7:16:21 AM (4 days ago) Apr 19
to Machine Learning for Kids
Dear Dale Lane:
       Thanks for your reply!  Yes, it's a hand-drawn digital shape with a transparent background. The goal is to enable the model to recognize which number the shape represents.  
        I coded the entire program by following this video, but the result is not what I expected.  The video link is:  
        Best Regards!
       Chen

Dale Lane

unread,
Apr 19, 2026, 7:23:24 AM (4 days ago) Apr 19
to Machine Learning for Kids
I assume that your training images, and the images you're using to test the model outside of Scratch, all have white backgrounds. 

The images that you're using in your Scratch project do not have a white background. 

In other words, the first thing that jumps out at me here is that you're saying your Scratch project is providing the ML model with a type of image that you've not trained it to recognise, or ever tested it with before. 

(I realise that to a human, a white background and a transparent background feel sort of equivalent or even synonymous. But to a machine, they're different.)

I don't know for a fact that this is why your model gives different answers in Scratch, but from the limited info I have - it's my first assumption, and the first thing I would recommend that you try.

Add a white background to your costume, giving the costume an aspect ratio that is roughly similar to what you've used in your training images. 

See how that changes the predictions from the model. 

Kind regards

D

PS - In many ways, I hope you see this as a positive thing happen in your project. My aim of Machine Learning for Kids is to let people get first hand experiences of the limitations and behaviours of machine learning technologies. What I'm describing here is a key lesson to learn about ML tech, and something you may not have thought about if it'd just magically worked for you despite the differences in your training and test images.  
On Friday, April 17, 2026 at 12:47:02 PM UTC+1 chen liao wrote:

chen liao

unread,
Apr 20, 2026, 4:01:25 AM (3 days ago) Apr 20
to Machine Learning for Kids
Dear Dane:
      
       Thank you very much for your patience and encouragement. I added a white background to the costume, and the results are consistent with expectations.
       
       Best Regards!
       
       Chen

Reply all
Reply to author
Forward
0 new messages