Tuesday, October 2, 2018

Regression vs Classification in Machine Learning

REGRESSION :
  • The output variable takes continues values
  • This predicts a value from a continue set
  • Regression involves estimating or predicting a response
  • e.g. The price of a house depending on the 'size', 'location' can be some 'numerical value'. This numerical value can be continues. 
  • Given  f : x -> y,  if y is real number/continues, then this is a regression problem.
  • Regression models makes predictions that answer questions like the following:
    • what is the value of a house in Taipei, Taiwan ?
    • what is the probability that a user click on this ad ?
  • Different types of regression :
    • Linear regression
    • Logistic regression
    • Polynomial regression
    • Stepwise regression
    • Ridge regression
    • Lasso regression
    • ElasticNet regression
    • and many more ....

CLASSIFICATION :
  • The output variable takes class labels
  • classification predicts the "belonging" to the class
  • classification is identifying group membership
  • e.g. The prediction of house price can be classified into 'very costly', 'costly', 'affordable', 'cheap', 'very cheap'. Here each class may correspond to some range of values.
  • Given  f : x -> y,  if y is discrete/categorical variable, then this is classification problem.
  • Classification model predict discrete values that ans. the questions like the following:
    • Is the given email message spam or not spam ?
    • Is this an image of dog, a cat or a hamster ?
  • Different classification methods:
    • Linear classifier: Logistic regression, Naive Bayes classifier
    • Support Vector Machines
    • Decision Trees
    • Boosted Trees
    • Random forest
    • Neural Networks
    • Nearest neighbor
    • and many more ....



[src] :

Tuesday, August 14, 2018

Difference between Classification and Clustering in Machine Learning



Classification
Clustering
What is it?
Given a set of historical/old data along with their class name and a set of new data, classification is the process of assigning each new data with class name that is obtained from the old/historical data. 
Given a set of samples/data, clustering is the process of grouping the data based on their similarities and the patterns of the data.
Type of input data
Set of data with label/class name
Only the data set. No labeling is required.
Input
  • A set of samples or data
  • A set of classes
A set of samples
Output
Class name of each new sample based on the classes of existing samples
Groupism of set of samples based on the data patterns. 
Each sample will be assigned with a group/label/class name.
Number of classes can be known.
Number of classes
Number of classes are known
Unknown number of classes. 
(number of classes can be known after clustering process is over)
Learning type
Supervised learning
Unsupervised learning
Algorithms
Decision tress
Bayesian classifier
SVM
K-mean
Expectation maximization
Dependencies
Depend on training data
no training data is required. No prior knowledge is required.





[src] : 

Friday, May 25, 2018

Classification using NaiveBayse Algorithm using Python

#Import Library of Gaussian Naive Bayes model
from sklearn.naive_bayes import GaussianNB
import numpy as np
import pandas as pd
 
#assigning predictor and target variables
dataF = pd.DataFrame()
dataF["x1"] = np.random.random_sample((5,)) + 1
dataF["x2"] = np.random.random_sample((5,)) + 2 

dataL = pd.DataFrame()
dataL = np.array([3, 3, 4, 3, 4])
 
#Create a Gaussian Classifier
model = GaussianNB()

# Train the model using the training sets 
model.fit(dataF, dataL)

#Predict Output 
predicted= model.predict([[1,2],[3,4]])
print(predicted)

Output: ([3,4])
 
-Thank you 

Wednesday, May 23, 2018

Basic Panda's functions for dataset manipulation in Python


Let we have two tables
Data1.schema:
    name:
    Company:
    Address:
Data2.schema:
    Name:
    gender:
    Age:

Commands:


# delete a column

del Data1[“name”]

# Return all the rows of the ‘name’ column

data1.loc[:, ‘name’]

# Return all the rows from ‘name’ column to ‘Company’ column

data1.loc[:, ‘name’:’Company’]

# Return all the rows from ‘Company’ column to ‘Address’ column

data1.loc[:, ‘Company’:’Address’]

# Return the rows whose Address is “India”

data1.loc[lambda var: var.Address == “India”, : ]
or
data1.loc[data1[“Address”] == “India”, :]

# Return only the name whose Address is “India”

data1.loc[lambda var: var.Address == “India”, ’name’]

# Return only the first five names whose Address is “India”

data1.loc[lambda var: var.Address == “India”, ’name’].head(5)

# Return only the last five names whose Address is “India”

data1.loc[lambda var: var.Address == “India”, ’name’].tail(5)

# Return the list of unique Addresses

data1.Address.unique()

# Return the list of unique Companies

data1.Company.unique()

# Return the list of unique names

data1.name.unique()

# Return the first unique Address

data1.Address.unique()[0]

# Return the total number of unique Addresses

data1.Address.unique().size

# Return the name, age and gender from data2 if the Address is India

t = data1.loc[data1[“Address”] == “India”, “name”].unique()
for x in range(0,t.size)
    data[2].loc[data2[“name”]==t[x],:]

Wednesday, May 2, 2018

Accessing remote GUI application using PuTTY

Extending the post in here, today we will see how the remote GUI applicaiton can be accessed using X server and the PuTTY.

Remote Server configuration:
  •     Ubuntu 16.04
  •     OpenSSH-server
Client machine configuration:
  •     Windows 8 or later
  •     Xming software tool

Remote server setup:
Install openssh-server package by executing following command:
sudo apt-get install openssh-server

Client machine setup:
  • Download Xming for Windows 8 64bit.
  • Install Xming executable file. You don't have to do any changes. Leave everything to the default selection.
  • Download and install the latest verion of the PuTTY from here.

  • Run Xming from the start menu or Issue the following command in command prompt
cd "c:\Program Files (x86)\Xming"
Xming.exe -multiwindow 
  •  Run PuTTY
  • In the PuTTY configuration window enter the IP address, port and select SSH radio button.

  • Select SSH from Connection category.
  • Check "Enable X11 forwarding" option and click on Open button. 


  • In the consol, now enter "gnome-calculator" to verify the above steps.
    Instead of  "gnome-calculator", you can enter command to access remote GUI application.
    I assume that, you know how to open your application from command line/ terminal.


Thats all for now.  


-Thanks


Monday, April 9, 2018

What is Virtual Network Function (VNF) ?

It is easy to understand the concept of VNF, if you know what is a Virtual Machine. In conventional manner, the network functions are embedded onto dedicated hardware. But, in some way, if we can make the network functions independent of the hardware and install it on any machine that will lead to the concept of VNF. 
Virtualized network functions or VNFs are the software realisations of the various network functions that can be deployed on a Network Functions Virtualization Infrastructure and needed to enable the network to operate. In this way, a VNF handles a specific network function that run on one or more virtual machines on top of the hardware networking infrastructure.

The individual VNF, can be considered to be building blocks and they can be connected or combined together, providing all the capabilities required to provide a complete networking communication service.

some examples of virtual network functions are 
     
  • Switching: BNG, CG-NAT, routers.
  • Tunnelling gateway elements: IPSec/SSL VPN gateways.
  • Traffic analysis: DPI, QoE measurementI.
  • Signalling: SBCs, IMS.
  • Application-level optimisation: CDNs, load Balancers.
  • Home routers and set top boxes.
  • Mobile network nodes: HLR/HSS, MME, SGSN, GGSN/PDN-GW, RNC.
  • Network-wide functions: AAA servers policy control, charging platforms.
  • Security functions: firewalls, intrusion detection systems, virus scanners, spam protection.
Later we will focus on Network Function Virtualization (NFV).

-Thanks

Thursday, March 29, 2018

Adding biography section into elsevier latex article


Mostly in research community Latex is used to write the articles that are published in different journals. Biography section is the last section in all articles. IEEEtran and elsarticle are the most widely used latex template which offer multiple commands to represent the research content/data in different manner. For example, IEEEbiography command is used to write the biography section in IEEEtran template. But no such similar command is available if you write the article using elsarticle template.

In reality, you don’t need any special command to write author’s biography if you are using elsarticle template. You can compare both the papers. The first paper is published in IEEE and the second is published in Elsevier.
IEEE paper: http://ieeexplore.ieee.org/document/8169111/?anchor=authors
Elsevier paper: https://www.sciencedirect.com/science/article/pii/S0164121216300887#b1

In elsarticle template, you can use following simple code to add biography section.


Code:

1
2
3
4
5
6
\pagebreak
% Biography Section
%\section*{ }
\noindent \textbf{Author1 name} author description goes here.
\subsection*{  } % This subsection (with no heading) is added to give more space between two biographies
\noindent \textbf{Author2 name}  author description goes here. 

Output:

I have observed that, most of the Elsevier journals add the biography section in new page. For this purpose \pagebreak command should be added

Usually in the biography section contains no title is given. For which either you can complete ignore use of \section command or you can use \section command with no title.

The entire content (From Line 1 to Line 6) should be at the end of the document but must be before \end{document} command.


-Thats all

Monday, March 19, 2018

Scheduling Ubuntu program with gnome-schedule

In Ubuntu you can schedule any task to run automatic or on a specific time.
For this either you can use gnome-schedule GUI or using crontab command.

Using gnome-schedule

=========================
1.   First make sure your program is running properly.
2.   Open the terminal (using Ctrl+Atl+t shortcut key).
3.   Enter the following command to install gnome-schedule
sudo apt-get install gnome-schedule
4.   Enter gnome-schedule command in the terminal window to open the desired GUI, as given below.

5.   Now click on "New" button.
6.   Select "A task that launches recurrently" option to execute the programm repeatedly in a specific time inerval.


7. Enter the Description and Command in corresponding fields.
8. Click Advanced radio button to explicitly mention the execution time. Now click on "Add" button.
    Examples:
                    Minute: 5, Hour: 15,  Day: *, Month: *, Weekday: *
                          This will execute the program Everyday, every month, at time 15:05 (3:05 PM)

    Click here to see some examples.  


Using crontab command

==========================
1.   Open terminal (using Ctrl+Atl+t shortcut key).
2.   Enter crontab -e
3.   Add one line in following format at the end of the file.
          <minute> <hours> <day> <month> <weekday> <Command to execute>
4.   Now save the file.

That's all.




Friday, March 16, 2018

Different ways to open a notification/dialoge box in Ubuntu

Different ways to display a dialog box or a status message in Ubuntu.

1.   notify-send -i /home/user/Desktop/notifications.ico "MsgSummary"  "This is message body !!!"

2.
     gxmessage "This is message body"
     gxmessage -file message.txt
     gxmessage -center -timeout 3 -fg RED -file message.sh

3.
     whiptail --msgbox "This is the message" 10 50
     whiptail --yesno "Press wither yes or no" 10 50

4.
     dialog --msgbox "This is the message" 10 50

5.
     zenity --info --text="Here is the message body"
     zenity --calendar
     zenity --color-selection
     zenity --password

Please see user manual of each command for more detailed information.
You can find more ways. Please comment if more options are there to display a message.


-Thanks

Thursday, March 15, 2018

Making the backup process simple and automatic

Let's we have two Ubuntu servers:

Server-1: IP: 1.2.3.10 (source server )
                 user account name: user1
                 user account password: user1
                
Server-2: IP: 1.2.3.11 (Destination server)

--------------------------------------------------

On Server-1
1. Install openssh-server. You may install through terminal.
2. configure openssh-server if needed, else leave it to the default configuration.

On Server-2
1.  Install openssh-server and sshpass through the terminal.
2.  Change the current directory to $USER/Desktop/backup
3.  Create the directory "data"
3.  Create a password file "pw.txt" with following content.
"pw.txt" content
user1
 4.  Create a shell script file with the name "backup.sh" with following content.
backup.sh content
sshpass -f pw.txt scp -r user1@1.2.3.10:data/*  /home/server2/backup/data/

5.  Make sure pw.txt and backup.sh files are in the same directory.
6.  Execute following command in the terminal
    bash backup.sh
   This  will copy all the content from user1@1.2.3.10:data/ path on Server-1 to /home/server2/backup/data/ directory on Server-2.

--------------------------------------------------

Now its time to schedule the bash backup.sh command to execute in a specific time interval

Make sure you have gone thorugh crontab manual page or gnome-schedule GUI. You may also go through this page to know more details on crontab and gnome-schedule.

1.  Open terminal
2.  Enter following command
crontab -e
3. If you are executing this command for the first time, it will ask for the choice to open an editor.
4. In the editor add following line at the end of the file.
0,12 * * * * bash /home/server2/backup/backup.sh
5. Save and exit the editor.

You can also use gnome-schedule command to schedule the "backup.sh"


-Thats all