Skip to content

Instantly share code, notes, and snippets.

View karimkhanp's full-sized avatar

Karimkhan karimkhanp

View GitHub Profile
@karimkhanp
karimkhanp / numerical_analysis
Created December 18, 2015 11:39
Numerical analysis tutorial
Libraries:
https://www.tensorflow.org/
Articles:
https://www.kaggle.com/c/titanic/details/getting-started-with-python
https://www.kaggle.com/c/titanic/details/getting-started-with-python-ii
"""
Using the words as features removing stopwords
"""
from sklearn.utils import check_random_state
from sklearn.datasets import load_files
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.feature_extraction.text import HashingVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics import accuracy_score, average_precision_score, f1_score, precision_score, recall_score
import sys
"""
NltkSentTokenize Class for all nltk sent tokenize
"""
class NltkSentTokenize(object):
"""
Initialization function of NltkSentTokenize Class
"""
def __init__(self):
@karimkhanp
karimkhanp / Python_for_beginners.txt
Created June 17, 2016 09:16
PYthon tutorials for beginners
Read basics about Python - http://www.tutorialspoint.com/python/python_overview.htm
Tutorials
http://www.tutorialspoint.com/python/index.htm
http://askpython.com/
More resources
https://wiki.python.org/moin/BeginnersGuide/Programmers
@karimkhanp
karimkhanp / install.txt
Last active June 17, 2016 10:46
Ubuntu new server installation
sudo apt-get install build-essential
wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar -xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure
make
make install
sudo apt-get install build-essential python-dev python-setuptools python-numpy python-scipy
@karimkhanp
karimkhanp / noun_phrase_extractor.py
Created July 26, 2016 12:00
Extracting the noun phrases using nltk
import nltk
from nltk.corpus import stopwords
text = raw_input("Enter the text please ...")
print text
sentence_re = r'(?:(?:[A-Z])(?:.[A-Z])+.?)|(?:\w+(?:-\w+)*)|(?:\$?\d+(?:.\d+)?%?)|(?:...|)(?:[][.,;"\'?():-_`])'
lemmatizer = nltk.WordNetLemmatizer()
stemmer = nltk.stem.porter.PorterStemmer()
grammar = r"""
@karimkhanp
karimkhanp / functions_py.py
Last active September 7, 2016 06:40
Useful python function
#Function to read xlsx files
def readExcel(self):
from xlrd import open_workbook
wb = open_workbook('Shortlisted Rumours Jan to June 2016.xlsx')
for s in wb.sheets():
for row in range(1, s.nrows):
# pdb.set_trace()
col_names = s.row(0)
col_value = []
@karimkhanp
karimkhanp / nltk_phrase_extractor.py
Last active October 4, 2016 08:29
nltk_Phrase_extractor.py
import nltk
from nltk.corpus import stopwords
class PhraseExtractor(object):
def __init__(self):
self.sentence_re = r'(?:(?:[A-Z])(?:.[A-Z])+.?)|(?:\w+(?:-\w+)*)|(?:\$?\d+(?:.\d+)?%?)|(?:...|)(?:[][.,;"\'?():-_`])'
self.lemmatizer = nltk.WordNetLemmatizer()
self.stemmer = nltk.stem.porter.PorterStemmer()
self.grammar = r"""
@karimkhanp
karimkhanp / svm-vs-nn
Created October 19, 2016 09:46
SVM vs NN - Why NN works better then SVM?
What is difference between SVM and Neural Network? Is it true that linear svm is same NN, and for non-linear separable problems, NN uses adding hidden layers and SVM uses changing space dimensions?
There are two parts to this question. The first part is "what is the form of function learned by these methods?" For NN and SVM this is typically the same. For example, a single hidden layer neural network uses exactly the same form of model as an SVM. That is:
Given an input vector x, the output is: output(x) = sum_over_all_i weight_i * nonlinear_function_i(x)
Generally the nonlinear functions will also have some parameters. So these methods need to learn how many nonlinear functions should be used, what their parameters are, and what the value of all the weight_i weights should be.
Therefore, the difference between a SVM and a NN is in how they decide what these parameters should be set to. Usually when someone says they are using a neural network they mean they are trying to find the parameters which minimiz
@karimkhanp
karimkhanp / chatbot.txt
Created November 24, 2016 11:00
Steps on how to build chatbot
What is Chatbot?
Types of Chatbot - Open domain vs Closed domain, Rules based vs General AI
Different approaches to build chatbots
Existing frameworks
Machine learning and NLP Based
AIML (Artificial Intelligence Markup Language)
How does each approach works.
IBM Watson, The most intelligent chatbot - Introduction
Modules to build open domain chatbot using NLP and Machine learning
Question Analysis