Skip to content

Instantly share code, notes, and snippets.

View saiplanner's full-sized avatar
🎯
Focusing

Venkata Sai Krishna Vanama saiplanner

🎯
Focusing
View GitHub Profile
@saiplanner
saiplanner / twitter crawler.txt
Created May 7, 2019 05:56 — forked from vickyqian/twitter crawler.txt
A Python script to download all the tweets of a hashtag into a csv
import tweepy
import csv
import pandas as pd
####input your credentials here
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
@saiplanner
saiplanner / getfeaturevector
Created May 7, 2019 06:17 — forked from vickyqian/getfeaturevector
Get Feature Vector
def getFeatureVector(tweet):
featureVector = []
#split tweet into words
words = tweet.split()
for w in words:
#replace two or more with two occurrences
w = replaceTwoOrMore(w)
#strip punctuation
w = w.strip('\'"?,.')
#check if the word stats with an alphabet
###Preprocess tweets
def processTweet2(tweet):
# process the tweets
#Convert to lower case
tweet = tweet.lower()
#Convert www.* or https?://* to URL
tweet = re.sub('((www\.[^\s]+)|(https?://[^\s]+))','URL',tweet)
#Convert @username to AT_USER
tweet = re.sub('@[^\s]+','AT_USER',tweet)
@saiplanner
saiplanner / naivebayes
Created May 7, 2019 06:19 — forked from vickyqian/naivebayes
Naive Bayes Classifier
import nltk
training_set = nltk.classify.util.apply_features(extract_features, tweets)
# Train the classifier Naive Bayes Classifier
NBClassifier = nltk.NaiveBayesClassifier.train(training_set)
#ua is a dataframe containing all the united airline tweets
ua['sentiment'] = ua['tweets'].apply(lambda tweet: NBClassifier.classify(extract_features(getFeatureVector(processTweet2(tweet)))))
@saiplanner
saiplanner / kittler.py
Created May 16, 2019 06:47 — forked from al42and/kittler.py
Kittler-Illingworth Thresholding
import numpy as np
def Kittler(im, out):
"""
The reimplementation of Kittler-Illingworth Thresholding algorithm by Bob Pepin
Works on 8-bit images only
Original Matlab code: https://www.mathworks.com/matlabcentral/fileexchange/45685-kittler-illingworth-thresholding
Paper: Kittler, J. & Illingworth, J. Minimum error thresholding. Pattern Recognit. 19, 41–47 (1986).
"""
h,g = np.histogram(im.ravel(),256,[0,256])
@saiplanner
saiplanner / spk.js
Created November 26, 2019 14:35 — forked from saketkunwar/spk.js
Google Earth Engine Speckle Noise Reduction
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD');
var poly = ee.Geometry.Polygon(
[[[-95.83648681640625, 29.561512529746743],
[-95.042724609375, 29.57345707301757],
[-95.02899169921875, 30.099989515377835],
[-95.82275390625, 30.10711788709236]]]);
var spatialFiltered = sentinel1.filter(ee.Filter.eq('instrumentMode', 'IW')).filterBounds(poly)
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.select('VV');
var image = spatialFiltered.filterDate('2017-08-25', '2017-09-05').mosaic().clip(poly);
@saiplanner
saiplanner / matchHistogram.js
Created November 25, 2020 11:08 — forked from flacle/matchHistogram.js
Histogram match - Google Earth Engine
/**
* # Histogram matching
* # Google Earth Engine with S1 SAR
* # A very small experiment :D
* # Author: Francis Laclé
* # Year: 2019
*/
/**
* Function that returns a normalized image using unitScale()