Friday, August 6, 2021

No-Code Data Science (Part 2)

In Part 1 of this post we covered no-code machine learning platforms in general. In this post I want to go through a few actual examples of how these types of platforms actually work. One thing that needs to be done regardless of the platform involved is to go through the input data (if it hasn't already been prepared for analysis) and get it in the proper format.

If you're supplying your own data the first step in building a machine learning model is to "clean" the input data that will be used to train the model. For example, let's say you have a voter file and want to make some predictions about voting patterns based on how long ago each person registered to vote. Some of the registration dates may be missing or incomplete (such as 9/22/0), some may be entered with dashes (5-14-1987) and others with slashes (5/14/1987), and some may obviously be incorrect (11-03-1847). The missing and incorrect entries need to be removed from the input data and the incomplete records may be removed or an attempt may be made to add the missing portion of the date. Once that's done, all the records need to formatted in the same way for  consistency. Data that's in some form other than numbers (such as images, sound clips, etc.) may require a different approach, but it will still require preparation of some type in order to use it to train a machine learning model.

At this point you're ready to choose a platform and begin building your ML model. These days there are quite a few no-code platforms to choose from - here are several examples:

  • Teachable Machine (https://teachablemachine.withgoogle.com/) - Google's Teachable Machine is a good place to start to get a feeling for how no-code AI platforms work. You can train models yourself to recognize certain images, sounds or poses (like whether you're sitting down or standing up), and host those models for free directly on the Teachable Machine website or in your own website or app. The models are built using TensorFlow.js, a JavaScript library for machine learning and are trained using a method called “transfer learning”. In transfer learning a fully trained neural network model is used, but the original training data is replace with your input. 

To see Teachable Machine in action search for: “Teachable Machine Tutorial: Bananameter” by Barron Webster (November 7, 2019). The tutorial shows  how he used Teachable Machine to identify images of bananas that aren't ripe yet, bananas that are ripe, and bananas that are past their prime. And for a more in-depth look at how Teachable Machine works, take a look at: “How to build a Teachable Machine with TensorFlow.js”, Nikhil Thorat – deeplearnjs.org.

  •  MonkeyLearn - MonkeyLearn is a no-code machine learning platform that specializes in text classification and extraction models which you can use to analyze your raw data in Microsoft Excel. To learn exactly how this works, there's a step-by-step explanation of the process involved at: https://monkeylearn.com/blog/machine-learning-in-excel/.
Scroll down the web page to the heading “How to use Machine Learning in Excel?” and follow the sequence of steps involved. The pre-trained model used is designed to do “sentiment analysis”. It analyzes customer comments uploaded from an Excel spreadsheet, predicts the main sentiment in each set of comments, and returns an Excel spreadsheet with a new column containing the model's predictions. There's also a section in the article covering how to create, train and use a “classification” model, as well as a link to a comprehensive guide to creating compelling data visualizations in Excel.

  • Peltarion - Peltarion has a detailed tutorial to help explain howdeep learning” models are built (https://peltarion.com/blog/applied-ai/defect-detection). The model is designed to detect surface defects in manufactured parts. Properly trained deep learning models are faster, more accurate and more consistent than manual inspections or software using traditional programming. Note: Deep learning is a subset of machine learning and deep learning models are normally trained with artificial neural network algorithms (algorithms that attempt to simulate the reasoning process of the human brain).

This particular model scans images of metal pump impellers and classifies them as either defective or not defective, which makes this a binary image classification problem. The details of how a deep learning model works can be complicated but you don't need to understand all the details in order to build a model like this. Rather than going through the whole process, I'll just list the steps involved:
    • Create a new project and give it a name.
    • Click the Data library button and search for the “Defects in metal casting” dataset.
    • If you agree with the dataset license, click “Accept” and import the data.
    • Next, you need to pre-process the data, which is split into 80% training data, 10% evaluation data (used to test the model on unlabeled data at the end of eachepoch” or training cycle to see how well the training is progressing), and 10% of the data which is saved for any further testing that may be needed.
    • Click the wrench icon to display theFeature Settings” and make sure “Encoding” is set to “binary” (since the model only has two outcomes - “true”, the part is defective and “false”, the part isn't defective). Also make sure “Positive class” is set to “true”.
    • Click “Save version”, then click “Use in new experiment”.
    • Note: The pre-processing is complete – the next step is to build the model.
    • Click Input(s)/Target” in the Experiment Wizard and make sure the Input feature is set to “Image” and the target is set to “Defective”.
    • Click the Snippet” tab and select “EfficientNet B0”.
    • Click the Weights” tab. The EfficientNet snippet can be trained with pre-trained weights (which allows you to make use of knowledge gained from another dataset). Using pre-trained weights saves time and improves efficiency.
    • Click “Create” to move to the Modeling View”.
    • Click on the “Input” block, select “Image augmentation” and click “Natural images”. Image augmentation adds more variation to the images – it isn't necessary, but it may help to increase the model's accuracy.
    • Click “Run” to start the experiment running.
    • Once the experiment has run to completion, click Evaluation” at the top of the screen to view the results.
    • There are a number of “loss metrics” in the Evaluation view, but the primary ones for this experiment are “binary accuracy” (the percentage of correct predictions) and “recall” (the percentage of actual defective parts that were classified as defective by the model).
    • To inspect the model's predictions, select the subset and epoch (training cycle) you want to look at and click “Inspect”.
    • There are four possibilities for each prediction the model makes – a non-defective impeller is classified correctly as not defective (“false”), a non-defective impeller is classified incorrectly as “defective” (“true”), a defective impeller is classified correctly as defective (“true”), or a defective impeller is classified incorrectly as not defective (“false”).
    • Looking at theConfusion Matrix” will show the percentages of each outcome (true positive, true negative, false positive, and false negative). Those figures will tell you a lot about how well the model did, but the most important statistic is the number of false negatives (which results in sending out a defective part). Another important metric is the ROC (Receiver Operating Characteristic) curve, which plots true positive rates versus false positive rates.

Once the model has been trained, the final step is to deploy it and see how it performs on new data that it hasn't seen before. Here's how to deploy the model:

    • Download and unzip the test data (the portion of the data that wasn't used to train the model).
    • Go to theDeployment view” and click “New deployment”.
    • When the “Create deployment” screen displays, select the experiment you want to deploy and choose the epoch (training cycle) that had the best results to be your checkpoint.
    • Click the “Enable” button to deploy the experiment.
    • Click the “Test deployment” button to try the model out on the test data you downloaded.

If there's a problem with the results of the deployment test, you can review the different reports from the training run and see if you want to make changes in the project setup and rerun the experiment.

That's a quick look at how no-code AI platforms work. Since this is one of the fastest growing parts of the no-code landscape I plan on doing several more posts on this topic in the near future. In the meantime, there are many other platforms like the ones mentioned above - if you're interested in machine learning, by all means pick one and try building a few models yourself. 


No comments:

Post a Comment