Skip to main content

Machine Learning

SIMPLE PREDICTION MODEL


Mean

Suppose you have given sales data of a certain commodity of past years and someone asks you to predict the sale for this year. Without any knowledge of machine learning algorithm, you can say that it will be approximate average/mean sales of past few years.

Mean is computed by dividing the sum of all values by the number of values.
                         
It's a good start but it's also important to know the accuracy of our model. There are many methods which we can use to evaluate how good is our model. Most commonly used method is mean square error (MSE).

Mean Square Error

The simple way to calculate mean square error is calculating the difference between actual values and the predicted value. However, we can't add it simply because the positive and the negative error may cancel each other so square these error before adding.  And divide the sum by the number of data point to calculate the mean error.  



It's always important to calculate the error in our model so that we efficiently use resources. Let's implement this model in python.

Installation 

sudo apt-get install python3-pip  
sudo pip3 install numpy
sudo -H pip3 install pandas 

Source Code

import pandas as pd 
import numpy as np

file = path_of_your_csv_data_file
#read csv
df = pd.read_csv(file)
#convert data frame to numpy array
df = df.values 
# select amount column from df, here it is in 3rd colum i.e 2 
amount = df[:, 2]
# calcaulate average amount of sale in past year 
mean_ = amount.mean(axis=0)
print ('Mean ', mean_)
#calculate mse
mse = ((mean_ - amount)**2).mean(axis=0)
print ('mse', mse)
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Comments

Popular posts from this blog

How Machine Learning (ML) Work

How Machine Learning (ML) Work In this post, We will learn how machine learning work. What is machine learning (ML) ? Machine learning is a study of model that compute use to progressively improve their performance on a specific task. What is Machine learning models ? Machine learning model contains a set of instruction or mathematical formula or in simple word it contain a piece of code in which we provide some data as input and model return some output. We learn more about model and how use a machine leaning model latter. How Machine Learning (ML) Work  ? This part we will understand with an example. Suppose want to have a simple application which will take a picture and banana or apple and application will tell us either it is banana or apple or picture is neither banana nor apple. To solve this problem first we provide a set of banana picture to our model and we will tell our model that this is a banana picture similarly we will provide a set of apple...

Arithmetic Expression Problem

Arithmetic Expression Problem In this post, We will share some arithmetic operation problems. Please solve it and your answer in comment section. Solution of all problem are available here  Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

HLL Infra Tech Services Ltd

HLL Infra Tech Services Ltd  Recruitment Company Name HITES Post Name Chief Engineer State India Salary Rs  32,900-58,000 Number of Vacancy 06 Eligibility Degree in Engineering Last Date 10-12-2018 Application Details Job Notification Apply Online TBD HLL Infra Tech Services Ltd Recruitment Government Jobs in  India Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Install Adminer

ADMINER APACHE Adminer is a tool for managing content in databases. In this post, We learn how to install Adminer on ubuntu. Install Adminer To install Adminer run sudo apt install adminer Configuration  Copy the configuration to your config folder and enable it sudo cp /etc/adminer/apache.conf /etc/apache2/conf-available/adminer.conf  sudo a2enconf adminer Reload Apache systemctl reload apache2 Run Adminer Open your favorite browser and type localhost/adminer/ or  localhost/adminer.php/ Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.