Table of Contents

set () as ()

Description

The block sets the input for the number classification and regression model to the specified value. The dropdown of the inputs is dynamically populated according to the ML model trained.

For example, in the IRIS example, there are four inputs that can be used in the block:

 

Example

Learn about noun detectors, tools or algorithms designed to identify and extract nouns from text or speech inputs.

Introduction

A noun detector is a tool or algorithm designed to identify and extract nouns from a given text or speech input. Nouns are a type of word that typically represent people, places, things, or ideas. In the context of chat-based applications, a noun detector can be useful for extracting key information or identifying specific entities mentioned in a conversation. It can help in tasks such as named entity recognition, information retrieval, sentiment analysis, and many more.
A noun detector serves as a valuable component in language processing systems, helping to extract and utilize meaningful information from text or speech inputs in chat-based interactions.

Logic

First, ChatGPT generates random sentences, and we save this response in a variable. Then, it asks users to identify a noun from the given sentence. If the user’s answer matches the response generated by ChatGPT, it will say “Correct.” Otherwise, it will say “Incorrect answer.”

  1. Open PictoBlox and create a new file.
  2. Select the environment as appropriate Block Coding Environment.
  3. To add the ChatGPT extension, click on the extension button located as shown in the image. This will enable the ChatGPT extension, allowing you to incorporate its capabilities into your project.
  4. We drag and drop the “Ask (AI)” block from the ChatExtension, and we use it to ask for any random sentence as input from chatGPT.
  5. We create a new variable called sentence and assign the value of a random sentence generated by ChatGPT to it.
  6. Use the say() method to provide instructions for finding nouns in the given sentence.
  7. Drag and drop the get() from the () block from the ChatGPT extension to obtain information from the sentence.
  8. If we use an if-else loop, we prompt the user to identify a noun from a given sentence. If the user’s answer matches the response generated by ChatGPT, it will say Correct answer for 2 minutes.
  9. Otherwise, if the user’s answer does not match the response from ChatGPT, it will return Answer is not a noun for 2 seconds.
  10. To begin the script, simply click on the green flag button.

Code

Output

Read More
The example shows how to use a number classifier in PictoBlox to make the Iris Classifier Bot.

Script

The idea is simple, we’ll add one image of  each class in the “costume” column by making one new sprite which will we display on the stage according to input from user. we’ll also change name of the image according to iris type.

  1. Add iris image as another sprite and upload one image of all iris classes on costume.
  2. Now, come back to the coding tab and select the Tobi sprite.
  3. We’ll start by adding a when flag clicked block from the Events palette.
  4. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  5. Add the “set () as ()” block from the Machine Learning palette. Select the SepalLengthCm option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  6. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  7. Add the “set () as ()” block from the Machine Learning palette. Select the SepalWidthCm option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  8. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  9. Add the “set () as ()” block from the Machine Learning palette. Select the PetalLengthCm option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  10. Add an “ask () and wait” block from the Sensing palette. Write an appropriate statement in an empty place.
  11. Add the “set () as ()” block from the Machine Learning palette. Select the PetalWidthCm option at the first empty place, and for the second select an “answer” block from the Sensing palette.
  12. Add an “analyse numbers” block from the Machine Learning palette.
  13. Add the “if () then” block from the control palette for checking the user’s input.
  14. In the empty place of the “if () then” block, add an “is identified class ()” block from the Machine Learning palette. Select the appropriate class from the options.
  15. Inside the “if () then” block, add an “say ()” block from the Looks palette block. Write an appropriate statement in an empty place.
  16. Inside the “if () then” block, add a “broadcast ()” block from the Events palette block. Select the “New message” option and write an appropriate statement for broadcasting a message to another sprite.
  17. Repeat “if () then” block code for other iris classes, make appropriate changes in copying block code according to other classes, and add code just below it.
  18. Final code of “Tobi” sprite is
  19. Now click on another sprite and write code.
  20. We’ll start writing code for this sprite by adding a when flag is clicked block from the Events palette.
  21. Add the “hide” block from the Looks pallet.
  22. Write a new code in the same sprite according to class and add the “when I receive ()” block from the Events palette. Select the appropriate class from the options.
  23. Add the “show” block from the Looks pallet.
  24. Add the “switch costume to ()” block from the Looks palette. Select the appropriate class from the options.
  25. Repeat the same code for other classes and make changes according to the class.

    Final Result

Read More
This project demonstrates how to use Machine Learning Environment to make a machine–learning model that identifies the hand gestures and makes the Mars Rover move accordingly.

This project demonstrates how to use Machine Learning Environment to make a machine–learning model that identifies hand gestures and makes the Mars Rover move accordingly.

We are going to use the Hand Classifier of the Machine Learning Environment. The model works by analyzing your hand position with the help of 21 data points.

Hand Gesture Classifier Workflow

Follow the steps below:

  1. Open PictoBlox and create a new file.
  2. Select the coding environment as appropriate Coding Environment.
  3. Select the “Open ML Environment” option under the “Files” tab to access the ML Environment.
  4. Click on “Create New Project“.
  5. A window will open. Type in a project name of your choice and select the “Hand Gesture Classifier” extension. Click the “Create Project” button to open the Hand Pose Classifier window.
  6. You shall see the Classifier workflow with two classes already made for you. Your environment is all set. Now it’s time to upload the data.

Class in Hand Gesture Classifier

There are 2 things that you have to provide in a class:

  1. Class Name: It’s the name to which the class will be referred as.
  2. Hand Pose Data: This data can either be taken from the webcam or by uploading from local storage.

Note: You can add more classes to the projects using the Add Class button.

Adding Data to Class

You can perform the following operations to manipulate the data into a class.

  1. Naming the Class: You can rename the class by clicking on the edit button.
  2. Adding Data to the Class: You can add the data using the Webcam or by Uploading the files from the local folder.
    1. Webcam:
Note: You must add at least 20 samples to each of your classes for your model to train. More samples will lead to better results.

Training the Model

After data is added, it’s fit to be used in model training. In order to do this, we have to train the model. By training the model, we extract meaningful information from the hand pose, and that in turn updates the weights. Once these weights are saved, we can use our model to make predictions on data previously unseen.

The accuracy of the model should increase over time. The x-axis of the graph shows the epochs, and the y-axis represents the accuracy at the corresponding epoch. Remember, the higher the reading in the accuracy graph, the better the model. The range of the accuracy is 0 to 1.

Testing the Model

To test the model, simply enter the input values in the “Testing” panel and click on the “Predict” button.

The model will return the probability of the input belonging to the classes.

Export in Block Coding

Click on the “Export Model” button on the top right of the Testing box, and PictoBlox will load your model into the Block Coding Environment if you have opened the ML Environment in the Block Coding.

Logic

The Mars Roverwill move according to the following logic:

  1. When the forward gesture is detected – Mars Rover will move forward.
  2. When the backward gesture is detected –Mars Rover will move backward.
  3. When the left gesture is detected –Mars Rover  will turn left.
  4. When the right gesture is detected – Mars Rover will turn right.

Code

Logic

  1. First, we will initialize different Gesture classes.
  2. Then, we will open the recognition window, which will identify different poses and turn on the camera with a certain level of transparency to identify images from the stage.
  3. If the identified class from the analyzed image is “forward,” the Mars Rover will move forward at a specific speed.
  4. If the identified class is “backward,” the Mars Rover will move backward.
  5. If the identified class is “left,” the Mars Rover will move left.
  6. If the identified class is “right,” the Mars Rover will move right.
  7. Otherwise, the Mars Rover will be in the home position.

Output


Read More
All articles loaded
No more articles to load