Create ML: A GUI for training Neural Networks | by Dario Radečić | Towards Data Science

A couple of weeks ago I’ve bought a new laptop — a 2019 MacBook Pro and I’ve been loving it ever since. Naturally, I started experimenting with Swift and Xcode, mostly to create some dummy iOS apps. That’s where I discovered Create ML — a GUI tool for training custom neural networks.
Here’s a quick statement directly from the official Apple’s documentation:
Use Create ML with familiar tools like Swift and macOS playgrounds to create and train custom machine learning models on your Mac. You can train models to perform tasks like recognizing images, extracting meaning from text, or finding relationships between numerical values.[1]
Nice. So you can see, it’s not only for image classification like we will do today.
Just to make a note at the start, there will surely be a massive drawback to Create ML for most users — and that is the harsh requirement: you need to be on macOS.
It’s not the end of the world if you don’t have a Mac since solutions like MacInCloud.com exist. I haven’t tested them personally, so I cannot guarantee you’ll have a perfectly smooth experience — but it must be better than nothing.
So to recap, you’ll need to be running macOS if you want to follow along, and also install the latest version of Xcode.
The article is structured as follows:
Dataset download3 lines to train them allModel trainingModel evaluationModel savingConclusion and next steps
Dataset download
3 lines to train them all
Model training
Model evaluation
Model saving
Conclusion and next steps
Just to briefly mention, in the next article, we’ll create an iOS app and link our trained model to it. The GitHub repo already exists, so feel free to check it out.
As mentioned earlier, we’ll be making a Dog vs Cat image classifier, and the dataset can be download from here.
If you’ve downloaded and extracted it, inside the root folder you’ll have the following structure:
├── test│   ├── cat│   └── dog└── train    ├── cat    └── dog
There are two things you must be aware of here:
Subfolder names must be identical in both train and test foldersPredicted category names will be inferred from the subfolder names — ergo cat and dog here
Subfolder names must be identical in both train and test folders
Predicted category names will be inferred from the subfolder names — ergo cat and dog here
Still following? Great, let’s proceed and prepare everything before we start with the training process.
We can now open up Xcode and create a new Playground — a blank one for macOS:
Name it as you wish and click on Next. We are now presented with the following screen:
Great! In the left section, we’ll be writing our code and in the right one, we’ll be training our model.
We can now delete this placeholder code and enter the following 3 lines:
import CreateMLUIlet builder = MLImageClassifierBuilder()builder.showInLiveView()
Your screen should look like this:
Don’t worry about the deprecation warning as the code will work just fine. Now we can click on the blue play button below our code. After a couple of seconds you will be presented with this:
And that’s it, we can begin training!
Okay, literally the only thing you have to do now is to drag the train folder into this Drop Images To Begin Training section:
The training process will begin instantly, and as we have more than 20K training images it will obviously take some time. So grab a cup of coffee, have a break, or just watch the model train.
And now, sometime later (around half an hour on my machine) the model is trained:
As we can see, it performed excellently on the train set, it only remains to see how will it perform on previously unseen data — ergo on the test set. Let’s explore just that in the next section.
To evaluate the model on the test set, simply drag the test folder into Drop Images To Begin Testing section:
The testing process will take significantly less time, as we only have 2500 images for testing purposes. Nevertheless, feel free to take another break until it’s finished.
Okay, done yet? Cool. As we can see, accuracy on the test set is still impressive — 98%.
Now we know that our model is ready for production, let’s explore how to export it in the next section.
We’ll need to save this model so we can use it later in our iOS app. To do so, scroll up in the model training section and expand the dropdown:
If you are satisfied with the auto-filled options click on Save. Remember, by default the model will be saved to the Documents folder — so let’s just verify quickly that it’ there:
Awesome! Notice the .mlmodel extension? It is mandatory for any model you wish to deploy on iOS, so keep that in mind.
We’re finished for today, so let’s make a brief conclusion.
After all of this, you might be wondering how the heck the model performs so good? The official statement from Apple is as follows:
Create ML leverages the machine learning infrastructure built in to Apple products like Photos and Siri. This means your image classification and natural language models are smaller and take much less time to train.[2]
In a nutshell, it means that Apple has a lot of pre-trained models for which it only needs to adjust the output layer (also known as Transfer learning). If you’ve used ResNet or AlexNet before you know what I’m talking about.
But there you have it, around 30 minutes to train the model and achieve 98% accuracy on the test set — pretty impressive for only 3 lines of code.
Stay tuned for the following article, where we’ll incorporate this model into an iOS app.
Thanks for reading.
Loved the article? Become a Medium member to continue learning without limits. I’ll receive a portion of your membership fee if you use the following link, with no extra cost to you.