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?
When using TM you may be able to sort the entire List of images from highest probability to lowest using code similar to
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
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:
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.
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: