Linux by Ripudaman Singh

Image
Customize the Bash [Linux] Your terminal window generally has username@hostname but you can change that we will discuss here how to change it.   link for details: Read-1 Read-2 Read-3 Let's make the Example setup as in above picture with live time cp ~/.bashrc ~/.bashrc.bak  In case of a problem it will help to get back the old file  nano ~/.bashrc Add the follwing line at the Last PS1="\e[0;35m\w\e[m\n\@ \e[0;35m$\e[m " close the nano by ctrl X, Y enter. making Changes active by source ~/.bashrc To customize in your own way see the above links. Get the localhost at some other name [Linux] Open your terminal and type  sudo nano /etc/hosts map your name with localhost address like 127.0.0.1       localhost 127.0.1.1       ripudaman # The following lines are desirable for IPv6 capable hosts ::1 ctrl X, y enter All done you can access the localhost at your describe name for me its ripudaman (helpful when making twitt...

ML | K-NN

BASICS
KNN is a classification algo for SuperVised Learning
K - nearest neighbour

if we have 2 type of class and a point out of class
we have To tell which class that [oint belongs then we use K-NN algo

K is the parameter which tell how many near neighbour we have to see
if the max near neighbour is of class A then the point will belong to
class A

 generelly used for small dataset
 K = squt of all the numbers of point (all take odd value of K)

 we plot he Validation and error curve of our data Set :
 the minimum value of K for both the curve is taken as value of K

PSEUDO CODE
1 Load the data
2 Initialise the value of k
3 For getting the predicted class, iterate from 1 to total number of training data points
    Calculate the distance between test data and each row of training data.
    Here we will use Euclidean distance as our distance metric since it’s the most
    popular method. The other metrics that can be used are Chebyshev, cosine, etc.
    Sort the calculated distances in ascending order based on distance values
    Get top k rows from the sorted array
    Get the most frequent class of these rows
    Return the predicted class of max frequent

The point whose class is to be determined : we calculate its distance from all the point of classes
sort the distance in ascending order
and now we take K numbers from this sorted vector  (neighbour)
and check the class of each member in neighbour
Get the most frequent class in this neighbour and this wil be predicted class

WHAT WE HAVE TO DO?

choose the numbers of K neighbour
take the k nearest neighbour of the new data point according to the Euclidean distance
Among the K neighbour count the numbers of data point in each category
Assign the new data point to the category where you counted the most neighbour

Comments

Popular posts from this blog

GIT tool for GITHUB/

Linux by Ripudaman Singh

CS IT PDFS