Free Web Development Online Tutorials, Learn to Code
Machine learning tutorial for beginners in Python, Machine Learning Python Example

Machine Learning Tutorial python Example

If you are completely new to machine learning, then probably you should read my earlier post what is machine learning!

In this Python Machine Learning tutorial, you will learn how to perform basic price prediction using python machine learning API.

Python Machine Learning Libraries

Before you start learning python machine learning, I suggest you should get familiar with following python libraries, because during machine learning we will be using those libraries extensively, if you know those library code syntax, you will able to focus more on machine learning flow rather than wondering about those library-codes.

In our example below, we will be learning some of above libraries, so you need to install them in your local project.

What you learn in this machine learning tutorial ?

  1. Setting up environment

    First, we need to setup our python development environment by installing all required libraries as listed above.

  2. Create Dataset

    You need to create your dataset, You create dataset in any data source like any RDBMS or Excel or CSV anything.

  3. Loading Dataset

    At this stage, you need to load dataset into python object, so you can play with data, how to load data that will depend what data source you are working with, in my example i will load data from excel file.

  4. Analyzing Dataset

    You may need to understand data by changing order, removing columns, adding additional columns, grouping them etc. Get them ready to train and test algorithms.

  5. Visualizing Dataset.

    Now, you may want to see how visually data will look like, by plotting, charting etc. You can also save the visual representation in pdf format for future reference or reporting purpose.

  6. Evaluating different algorithms

    Try different algorithms to see which produce the best closest result

  7. Making predictions

    Finally, make prediction with real data.

What problem we solve!

In our example, we will predict fruit price based on previous year data.
Note: if you don’t have data you can download Taxi fare standard data for practice.

Start Python Console App

Start your SDE, we are using Visual Studio 2019 to write python console application for machine learning example. (You can use any Python SDE, code will remain same.)

First, we need to make sure that all required libraries are installed correctly, so let’s run the following code in your console.

print("We are learning Machine Learning at WebTrainingRoom")
import sys
print('Python: {}'.format(sys.version))
# install  matplotlib
import matplotlib
print('matplotlib: {}'.format(matplotlib.__version__))
# install pandas
import pandas
print('pandas: {}'.format(pandas.__version__))
# install scikit-learn
import sklearn
print('sklearn: {}'.format(sklearn.__version__))
# install scipy
import scipy
print('scipy: {}'.format(scipy.__version__))
# install numpy
import numpy
print('numpy: {}'.format(numpy.__version__))

If you are creating for first time, then you may need to install all packages one by one, to do that, expand your solution explorer, go to python environment, then right click to manage package, then run pip command, like pip install sklearn

Once you run the above code, here is the result you should see on your console screen, don’t worry if you see the different version. Core concept will remain same.

We are learning Machine Learning at WebTrainingRoom
Python: 3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 bit (AMD64)]
matplotlib: 3.1.3
pandas: 1.0.1
sklearn: 0.22.1
scipy: 1.4.1
numpy: 1.18.1
Press any key to continue . . .

in progress

 
Machine Learning Tutorial in python

learn data science

AI Machine Learning Examples