Posts

What makes aGood Features? Machine Learning Recipes.

Classifier are only as goof as the features you provide. that means coming up with good features, is one of the most important jobs in machine learning. But what makes a good feature and how can you tell ? If you are doing binary classification , then a good feature makes it easy to decide between things. ex- imagine we wanted to write a classifier to tell the difference between two dogs , greyhounds and labradors here we will use two features , the dogs height in inches and there eye color just for this toy example , lets make couple assumptions about dogs to keep things simple First - greyhounds usually taller than  labradors , next we will pretend that dogs have only two eye colors - blue and brown and we will say the color of eyes does not depends on breed of dog, this mean that one of these features is usefull and other tells us nothing.  

Supervised Learning : PRACTICAL Decision Tree classifier- Apple / Orange Classifier :

Image
Supervised Learning Recipe : 1. collect training data : These are the examples of problem we wan to solve.     for our problem we are going to write function  to classify piece of fruit. we will take a description of the fruit as input and predict weather its apple or an orange as output based on features. like texture(bumpy ,smooth) and wait To collect our training data imagine we haed out to an orchard. we will look at different apples and oranges  and write down measurements that describe them in a table. In Machine Learning these measurement called features . To  keep things simple we just used two. How much each fruit weights in grams and its texture which can be bumpy or smooth. A good features makes it easy to discriminate between different types of fruit . Each row in our training data is an example , it describes one piece of fruit.. The last column is called the label. It identifies what type of fruit in each row. and...

Decision Tree classifier on Iris data Sets Using Python sklearn

Image
 DataSet link : https://en.wikipedia.org/wiki/Iris_flower_data_set#Use_of_the_data_set from sklearn.datasets import load_iris #iris flower data set available in sklearn  #contain features and labels , like sapal length , sapal width , patellength #this data set avlbl in sklearn so we import from sklearn from sklearn import tree #to used decision tree classifier we need to import tree import numpy as np iris=load_iris() # load the dataset print (iris.feature_names) #print the features name print (iris.target_names) #print labels (target name) print (iris.data[ 0 ]) # length width print of first flower print (iris.target[ 0 ]) #print label of zero flower removed = [ 0 , 50 , 100 ] #removed this 3 rows from data set to find accuracy new_target=np.delete(iris.target , removed) new_data=np.delete(iris.data , removed , axis = 0 ) clf=tree.DecisionTreeClassifier() clf = clf.fit(new_data , new_target) //test prediction what is [0,50,100] prediction=c...

Data Science : Creating a news reader Python

Image
Go to newsapi  website and get url for any news channel . To code in python you need to add dependency for this run below command pip install newsapi-python and here is the code import urllib.request as urlr import json r=urlr.urlopen("http://newsapi.org/v2/top-headlines?sources=the-times-of-india&apiKey=460981db9cf744c08c14a5fc295431ac") a=json.loads(r.read().decode()); for i in range(0,5):     print(a['articles'][0]['title']) input()

Sentiment Analysis From tweeter

Sentiment Analysis  : Understanding and Extracting Feelings From Data An API lets you access an apps functionality from your code Note  : go to tweeter developer and generate secrete key , secrete access key, access token key , and access secrate token key TextBlob is awesome for NLP task pip install tweepy pip install textblob  import tweepy from textblob import TextBlob c_k= "ZTLY86W4SB7x8f5AsDrTYcIDG" c_s= "n4dWcwOYz19XS7FGRKWJt45jumtdHhw7njbKU64r3C0sMmAj8W" a_t= "497554636-3fXu3jG70a8P4sICR88Dnr8TYmMEKQn3LDVM6jiE" a_t_s= "GPfOWs5WH5cTWmUQs4O1BRPy3LPwkbFhmhtOABdjLZDEc" auth=tweepy.OAuthHandler(c_k , c_s) auth.set_access_token(a_t , a_t_s) api = tweepy.API(auth) public_tweets = api.search( "Amit Shah" ) for tweet in public_tweets: print (tweet.text) analysis=TextBlob(tweet.text) print (analysis.sentiment)

Installation python and Its Dependancy

Installing PIP (Python package Manager) pip install -U pip Adding dependancy by pip pip install -U scikit-learn

PyCharm IDE for Python On linux machine installtoin

Image
Step 1:  Type below link on URL and download IDE first             http://www.jetbrains.com/products.html#lang=python Step 2:  After downloading completion just extract the folder  Step 3:  copy pycharm bin folder path and set on terminal