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



Sunday, March 11, 2018

Installing Docker on Ubuntu 14.04 OS [Update]

Steps:

  s1:    sudo apt-get update
  s2:    sudo apt-get install \
                  apt-transport-https \
                  ca-certificates \
                  curl \
                  software-properties-common
  s3:    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  s4:    sudo add-apt-repository \
                  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
                  $(lsb_release -cs) \
                  stable edge"
  s5:    sudo apt-get update
  s6:    sudo apt-get install docker-ce
  s7:  For testing the docker
           sudo docker run hello-world

 Create the "docker" group
   sudo groupadd docker
Add the current user to the "docker" group
   sudo usermod -aG docker $USER

Now logout and then login again from the currnet session.

You can download and run the following shell script file.
InstallDocker.sh

Wednesday, August 23, 2017

Virtualization: The technology behind cloud

Virtualization is the dominant technology used to set up cloud environment. In traditional approach, without using virtualization technology, only one OS can be installed onto one physical machine. However, using virtualization technology, multiple machines can be created, called Virtual machines (VMs) or virtual server. In research articles, PMs are also referred to physical servers. Similarly, the physical resources are also refers to substrate resource. Now, lets understand the figure given below.




Fig: Type-1 and Type-2 hypervisor
[src]: https://commons.wikimedia.org/wiki/File:Hyperviseur.png#/media/File:Hyperviseur.png



The virtual machines can be created only with the help of a small piece of software call virtual machine monitor (VMM) or virtual manager that implements the virtualization technology. The VMM can be installed directly on the hardware (Type 1 in the above figure) or can be installed atop an OS (Type 2 in the above figure). When the VMM is installed atop an OS, that OS is called hosted OS and the OS that is installed in each virtual machine is called guest OS. This virtualization layer provides and environment for the VMs to interact with the hardware. Another major responsibility of virtualization layer is to maintain the isolation among the VMs or guest OSs.

Here question arises, how this technology helps us to setup a cloud environment. When the cloud user ask for a computer with the configuration 2GB memory, 2 processing units, 50GB storage, and 2mbps network connection, cloud service provider creates a VM with the configuration provided by the cloud user. The cloud user is than given a URL in order to establish a connection to the created VM. Cloud user has no information regarding the underlined PM upon which the VM is created. In general CSPs adopt the TYPE 1 (in the above figure) approach to create the VMs. multiple VMs are created upon single PM. Another major advantage of this virtualization technology is that, it is very easy to migrate a VM fromone PM to another. Users are also NOT given any facility to interact with the physical machine which make the PMs more secure from the outside attacker.

Here is the link to calculate the number of VMs per PM or Host. In today's date an average of 40-60 VMs are created on each PM.

Based on the where the VMM is installed and purpose of the installation, virtualization is of four types[1].
    1. Hardware Virtualization : If the VMM is install atop the hardware, e,i, Type 1 in the above figure
    2. OS Virtualization : If the VMM is install atop an Operating System, e.i. Type 2 in the above Figure
    3. Storage Virtualization : Here the VMM is installed on multiple storage servers, which forms a single storage system for the user.
    4. Server Virtualization: When the VMM installed to divide the single physical server system into multiple virtual servers.

Besides aforemention four types, virtualization can also be divided into data virtualization, memory virtualization, network virtualization etc categories[2].




Thats all about the basics of Virtualization. Please comment if you need more further detail information.

Thank you