Teachable Machine (probability sorting) problem

so im creating like an image classifer with it. But the problem a rose when i want it to detect whats the highest accuracy in the list.

my code


I have to repeat this 6 times, for each of the object, so that if the first 1 is not over 95, it will goes to check the next one
so, as you can , i used to use the personal image classifer :

as you can see, personal image classifer auto sort the list , to the highest possibility to the lowest. So the script find the first index, which is the highest possibility.

But teachable machine, doesn't do that, how can i make script to detetc which has the highest accuracy among all the object in the result list? I want to make script more efficient. can someone help me?

This might help.

Using Personal Image Classifier Personal image classifier display - #2 by SteveJG the list is automatic.

When using TM you may be able to sort the entire List of images from highest probability to lowest using code similar to

sortTMlist
Then item #1 in sortedImageList will be the highest probability.

Whether this will work or not depends on whether result is a number; if it is not you will need a different sorting algorithm. You might post what values result provides to help the community to see what might be required to order the list

1 Like

it does work, but it sort alphabetically not by accuracy. A-Z. not 100-0

As Steve has pointed to you, the sorting algorithm can be change depending on the result you have. Share your result here so someone can help you with the sorting issue.

I guess you have a list of elements, where each element is a list with name and percentage. Then it could be something like this:

1 Like

thiss.. I hope this help

Try the example above. That should sort the list based on the second element.

1 Like

Capture

it doesn't sort it or do anything..

What you said you were receiving (list of lists):

What you say you are receiving now (json):

Set a label with the "result" you are receiving, use DoIt to get it and paste it here.

this is the actual state of the list, thats why i said it doesn't sort it.. the first 1 actually did something.

and my i add, whats a dolt?

Try this for the new format:

as you can see DoIt is a feature (right click) to be able to see the content of, for example, a label.Text (you need to be connected by Companion or emulator) which is very useful for debugging the code.

oh you meant DO IT. thought it was dolt ._.

1 Like

what is that initalized local result to , do? exactly? should i copy that?

take your "result" that you receiving ,and you have pasted before, and use it like I do with "name2" in the example. As you can see I have set in "name2" variable the same json you are receiving (something similar you have pasted in the last image).

So, then you need to decode the json, and once decoded like a list, then order it. I use "result" like a local variable to set the decoded json, and to use it in the before sorting block.

You can use the variable names that you want.

Take a look to the difference between the json received and the list of lists after decoding:

Once you have a list of list, then you can sort it like before, checking the second element (the integer).

like this?? Actually i have no idea , after you changed the pic
Capture

You should see the ordered list in Classify.

1 Like

yep is the solution, thank you!

1 Like

Great! you're welcome

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.