To create your own machine-learning model, you first need to install some tools. Among them is an editor to write Python code, and some command-line tools.
- [Instructor] Many tools that are used in the machine learning community are written in Python. And we're also going to write some Python code later to create a custom machine learning model. But before we can do that, we need to install some requirements on your machine. And also maybe a new text editor that allows us to easily write some Python code and run it on the console. If you prefer another editor, just go for it. I'm going to suggest the Atom editor for this training since it's completely free.
And there are some great packages that we can install into it. But later, more about the editor. Let's now focus on installing all the requirements. And first of all, you should open up your terminal using Spotlight for example. And now, I have my empty terminal window here. And first of all, I'd like to check if Python is installed on my system. So I'm just writing Python --version here. And this should give me a version number and if it does on your machine as well, then Python is installed and actually it should be installed since it comes with every Mac OS installation.
And now that we are sure that Python is installed, what we can do is also installing a Python package manager, which is called Pip. And Pip is going to allow us later to install more packages so this is something that we should definitely run now. And I'm going to use a sudo command here only this time. This is the only time that you're going to do something as a super user, so I'm using sudo easy_install pip, which is our package manager. And after this installation is done, we can continue.
And what I'd like to do now first is downloading another tool, which is called virtual environment. And this solves the problem that if you're running multiple Python projects and there are probably conflicting requirements or packages, then we can put every project into its own virtual environment, which is really cool. And to install a virtual environment, what we need is Pip. So I'm going to call Pip here. And what I'd like to do is install and directly upgrade virtualenv for virtual environment.
And on my machine, this is already up-to-date. Depending on your internet speed, this might take some time to download and install. But if you're finished, then we can directly continue creating a new virtual environment for us. The virtual environment is going to be created automatically in the directory that you're currently in. And I'm going to use my home directory now. And all I need to do to create one is calling virtualenv and I'm going to call it machineLearningEnv.
And hit Return. And this is now created on my system. If I press LS, then you can see that machineLearningEnv has been added to my directory. And now to activate this virtual environment, all I need to do is call source, go into my machineLearningEnv folder, go into the bin folder, and hit activate. Now, I hit Return and now, this machineLearningEnv indicates that I'm currently running this virtual environment.
And in this virtual environment, what I'd like to do is installing now Turi Create. So all I need to do now is running Pip, calling install, and upgrade Turi Create. So I hit Return. And what I have to do is now create a new rule, maybe for my firewall, allowing that. And now, again, depending on your internet speed, this is going to take some time to download all the requirements. And also downloading Turi Create.
And once it's finished, we can continue. Now, my installation is completed. And now, to actually test if Turi Create is available, what I can do is opening up Python here in my terminal. Just hitting Python. And I can now import or write import turicreate. And if this does not return an error, then Turi Create has successfully been installed. And since we're not going to write some Python code in the terminal, what we need to do is working with a text editor.
You could work with X-code, you could work with the text editor, but you could also download a dedicated editor for this purpose. I'm going to suggest for this training the Atom text editor. And the cool thing about Atom is that we can directly integrate a console or a terminal into this editor. So go ahead and download that for free if you like or just choose your personal editor of liking. And I've already downloaded and installed Atom. And to actually get our project into the Atom editor, what I can do is right-click here in the Project section and add a project folder.
And I have already created a Coreml folder for another training, but now, what we need here is selecting our virtual environment, which is machineLearningEnv in my case. I'm in my home directory, I open that up. And then we have all the files that are related to the virtual environment here, but I can also create a new Python file later right in my machine learning environment. And what I'd also like to do is installing a package that allows us to display a terminal right here.
And this is very cool, because we can directly run all the commands that we need from our editor then. And to actually install this package, all you need to do is press Command-comma on your keyboard and this opens up the settings. And I'm just going to close the terminal here. And what I'd like to do is install something in here. We just search for platform-ide-terminal. Looking for that and as soon as we have found that, we can just hit the Install button.
And as soon as this package is installed, you will find this little plus icon in the lower left corner. And once I click it, we open up a standard terminal, where I can just show something, move upwards, and so on. Going to my machine learning environment, seeing all the content here. So this is very cool. And with that, we've installed all the requirements that we need. Just to quickly recap, we have installed Turi Create now into a virtual environment, which is a folder in your home directory.
And every time you want to use Turi Create or run some code, what we have to do is to open up or to start the virtual environment by hitting the source machineLearningEnv/bin/activate command in the terminal to make sure that we can also import Turi Create into our Python code. And with all that done, we are definitely ready to go and learn some bits and pieces about Python.
- Using Turi Create to create custom models
- Getting comfortable with Python
- Preparing data for Turi Create
- Creating a machine learning model with Turi Create
- Implementing an image picker controller
- Using Core ML and the Vision framework for image classification