How To Get Started With Machine Learning In Python
Up and Running with Machine Learning In Python
Hello Devs, Today I will guide you How To Get Started With Machine Learning In Python. In this tutorial, you will learn to install the Python3, Jupyter Notebook, Scikit Learn, and other useful Python libraries step by step. Also if you do not want to install all the packages one by one, then you can also install only one software called Anaconda. It will install Python3 and other I guess 150 packages that will help you to build your development environment very smoothly and you do not even think about installing all the dependencies.
- 1 What Is Machine Learning?
- 2 Machine Learning WorkFlow
- 3 Get Started With Machine Learning In Python
- 4 Method: 1 Install Dependencies Using Anaconda.
- 5 Method 2: Install Individual Libraries.
- 6 Getting Started With Jupyter Notebook.
- 7 Markdown Editor
- 8 Code In Jupyter Notebook.
What Is Machine Learning?
Machine Learning is the application of Artificial Intelligence (AI) that provides systems the ability to learn and improve from the previous experience without being explicitly programmed automatically. Machine learning focuses on the development of computer programs that can access the data and use it to determine themselves for future making decisions.
The process of learning begins with the measurements or observations of data, such as examples, direct experience, or instruction, to look for patterns in data and make better decisions in the future based on the models that we can provide. The primary focus is to allow the computers to learn automatically without human intervention or assistance and adjust actions accordingly.
Machine Learning is the art of computing, in which we need first to prepare the data, if not in well-formed condition and then use that accurate data to train the models. The models are built on different algorithms, which the programmers need to write in programming language and our case it is Python. Based on the previous output of the data and algorithmic logic, Machine starts to learn themselves, and the accuracy of the future values are accurate more and more based on the vast amount of data that we have collected.
Machine Learning WorkFlow
The necessary steps are following.
- We need to ask our selves, what are the main problems that can solve machine learning.
- After identifying the problem, we need to start the preparing for the data. If the data is not well organized than we need to organize it very well so that we can train the model based on accurate data.
- Next step is to select the algorithm that can solve the problem. There are so many algorithms out there to work with, but we need to identify the perfect algorithm to meet our requirement.
- After selecting the Algorithm, we need to train the model based on that.
- The last step is to test that model to predict the future values.
Get Started With Machine Learning In Python
The first thing we will do is to install the Python 3 and other machine learning libraries that we can use to develop and train the models. I am using Mac, but if you are the windows user, then you can also follow up this tutorial although installation instructions might be different on Windows platform. You can easily google for that, not a big deal. Once you install all the libraries, you are ready to go with this tutorial.
There are lots of ways, you can install all the dependencies, but I am showing two methods from them
- Install Anaconda package that covers all the installation libraries. You need to launch the Navigator and open the Jupyter Notebook, and you are good to go.
- We will install all the dependencies one by one on Mac.
Method: 1 Install Dependencies Using Anaconda.
Step 1: Install Anaconda
Go to the downloads directory https://www.anaconda.com/download/#macos
For Windows users, choose your platform’s executables and download the package and install it on your machine.
During the installation, you have an option that tells us that, whether or not you need to install Visual Studio Code or not. Guys, if you have not downloaded already then, please download and install it on your machine.
After installing, we need to open the application from Launchpad called Anaconda-Navigator.
I have already installed VSCode, so do not need to install it from here. But almost our interface looks same.
Step 3: Launch Jupyter Notebook.
It will start a server at default PORT: 8888. Also, it will open the browser window and take to this local URL: http://localhost:8888/tree, Please do not close the terminal that opens with Jupyter Notebook otherwise our local server will stop working and we will not be able to run the Jupyter Notebook. So we all set up to start Machine Learning.
Method 2: Install Individual Libraries.
First, check your Python version using the following command.
On my MacBook, I have preinstalled Python, and its version is 2.7. But we need the different version, and that is Python 3. Do not uninstall old version because otherwise, your some of the mac applications will be stopped. Instead, pull another version of Python by the following command.
brew install python3
Okay, so it will install the Python3, and now you can check it using the following command.
Now, you can see that Python3 is installed on our machine.
Finally, install the following packages using Pip. It is the Python, package manager.
python3 -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
So it will install all the dependencies. Now, go to your terminal and hit the following command to start Jupyter server.
Now, switch to the browser and type this URL: http://localhost:8888/tree
You can see that our Jupyter Notebook server is running correctly.
Getting Started With Jupyter Notebook.
So, now we need to create one notebook.
Go into your project folder, and in my case it is AnacondaProjects. It is empty so press new drop-down in the upper right corner and select python3. You will see something like below.
I have renamed the title to FirstML. Yours would be untitled. My Browser URL is like this: http://localhost:8888/notebooks/AnacondaProjects/FirstML.ipynb Your URL will be different based on your folder structure.
If you have used Github before then, I guess you are familiar with Markdown Language. Markdown is a lightweight markup language with plain text formatting syntax. It is designed so that it can be converted to HTML and many other formats using a tool by the same name.
In Github, we are writing this language inside readme.md file. So that the project can be described very well and it can be documented very well.
In Jupyter Notebook, when we need to write something that is not code, we can change it to via drop-down and select the markdown instead and write some text in markdown language. For example, If we need to write H1 text in markdown, then we can write it using the following syntax.
# Hello Machine Learning
So it will print as an H1 text. Same if we define two hashes then H2 text and go on.
Code In Jupyter Notebook.
We can write the code and run the code like following.
First, if your dropdown says markdown then change it to code and then write the code. After that, to run that code type shortcut shift + enter(return)
You will get an output like the above image. Great!!. So we have set up all correctly.
We will start working with data in the next tutorial. How To Get Started With Machine Learning In Python tutorial is over. This is a just basic overview of machine learning and installing the dependencies related to machine learning. Stay tuned for the next machine learning tutorial.