Skip to content

Instantly share code, notes, and snippets.

@shantanuo
shantanuo / tf_learn.py
Created February 10, 2019 07:18
tensorflow code
# https://towardsdatascience.com/transfer-learning-using-elmo-embedding-c4a7e415103c
import pandas as pd
import numpy as np
import re
import tensorflow_hub as hub
import tensorflow as tf
import keras
from tensorflow.python.keras.layers import Input, Dense, Lambda
old = pd.read_excel('../data/sample-address-1.xlsx', 'Sheet1', na_values=['NA'])
new = pd.read_excel('../data/sample-address-2.xlsx', 'Sheet1', na_values=['NA'])
old['version'] = "old"
new['version'] = "new"
all_data = pd.concat([old, new], axis='rows', ignore_index=True)
changes = all_data.reset_index().drop_duplicates(subset=["account number", "name", "street", "city","state", "postal code"], keep=False)
problem=changes['account number'].unique()
@shantanuo
shantanuo / medium_claps.py
Created January 30, 2019 04:34
List recent claps from medium blog
import requests
import json
def clean_json_response(response):
return json.loads(response.text.split('])}while(1);</x>')[1])
url = 'https://medium.com/@user/has-recommended?format=json'
mylist=list()
response = requests.get(url)
response_dict = clean_json_response(response)
@shantanuo
shantanuo / load_data.py
Created January 22, 2019 05:09
convert medical images to numpy array
############Load libraries#####################################################
import cv2
import numpy as np
import os
from keras.utils import np_utils
###############################################################################
#cross-validation at the patient level
train_data_dir = '/home/ec2-user/SageMaker/malaria-detection-model/malaria/training'
valid_data_dir = '/home/ec2-user/SageMaker/malaria-detection-model/malaria/validation'
###############################################################################
@shantanuo
shantanuo / test.csv
Created January 15, 2019 13:11
load this file in padas
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
5432 some_code case0 this is ok 6 20181201031613
@shantanuo
shantanuo / test.csv
Created December 22, 2018 08:37
test csv
We can make this file beautiful and searchable if this error is corrected: Any value after quoted field isn't allowed in line 4.
"%_first_name", "Very_long_column_names_with_CAPITAL_LetteRS_and_also_%$#@!", "Very_long_column_names_with_CAPITAL_LetteRS", "Very_long_column_names"
"shantanu", "Mumbai", "Maharashtra", "India"
"Amar", "Delhi", "Delhi", "India"
"Akbar", "Madras", "Tamil Nadu" , "India"
@shantanuo
shantanuo / marathi_nlp.py
Created November 22, 2018 05:10
Get words from Marathi text
! git clone https://github.com/cltk/marathi_text_wikisource.git
from collections import Counter
from nltk import word_tokenize
import pandas as pd
import os
fdist = Counter()
import os
@shantanuo
shantanuo / hunspell.py
Created October 30, 2018 12:56
hunspell python package for reverse engineering of words
docker run -it -v /tmp/:/usr/src/myapp -w /usr/src/myapp python:3 bash
apt-get update
apt-get install python-dev
apt-get install libhunspell-dev
pip install hunspell
import hunspell
hobj = hunspell.HunSpell('mr_IN1.dic', 'mr_IN1.aff')
for x in hobj.stem('घोड्याचा'):
print (x.decode('utf-8'))
@shantanuo
shantanuo / nlp.py
Created August 19, 2018 11:35
NLP using spacy and other modules
## install
# apt-get update && apt-get install -y \
build-essential \
wget \
git \
python-dev \
unzip \
python-numpy \
python-scipy \
&& rm -rf /var/cache/apk/*
@shantanuo
shantanuo / github_trending.py
Created August 9, 2018 13:42
scrap website using python