Skip to content

Instantly share code, notes, and snippets.

View sureshgorakala's full-sized avatar

Suresh Gorakala sureshgorakala

  • www.dataperspective.info
View GitHub Profile
@sureshgorakala
sureshgorakala / server.R
Last active December 21, 2015 20:39
Shiny App Demo
library(tm)
library(twitteR)
library(stringr)
library(plyr)
#get the tweets
#tweets = local(get(load('D:/SureshPersonal/Coursera/SentiAnalysis/Twitter/CE.RData')))
tweets = local(get(load('C:/shiny/sat.RData')))
tweets_txt = sapply(tweets,function(x) x$getText())
@sureshgorakala
sureshgorakala / server.R
Last active August 29, 2015 13:56
Shiny Server Demo
library(shiny)
shinyServer(function(input, output) {
#ds = read.csv("data.csv")
ds = local(get(load("C:/Users/S769346/Desktop/SAFETY DATA ANALYSIS/SAFETY DATA ANALYSIS/test/df.rData")))
xn = as.POSIXct(ds$"Date.of.Occurence",format="%m/%d/%Y")
ds["year"] = as.numeric(format(xn,"%Y"))
ds["month"] = as.numeric(format(xn,"%m"))
library(twitteR)
library(tm)
library(stringr)
library(wordcloud)
#fetch data
load("D:/Suresh R&D/Emirates Airlines SNA/twitteR_credentials")
registerTwitterOAuth(twitCred)
tweets = searchTwitter("@emirates", lang="en",cainfo="D:/Suresh R&D/Emirates Airlines SNA/cacert.pem")
#remove retweets
@sureshgorakala
sureshgorakala / include.html
Last active August 29, 2015 14:01
HTML test
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>HTML UI</h1>
<table>
@sureshgorakala
sureshgorakala / blogpost.r
Last active December 5, 2015 13:57
BloggerGist
#mean of the rows
apply(m, 1, mean)
# mean of the columns
apply(m, 2, mean)
# divide all values by 2
apply(m, 1:2, function(x) x/2)
@sureshgorakala
sureshgorakala / Codefile
Created December 10, 2015 00:29
chi-square of Independence
import pandas
import numpy
import scipy.stats
import seaborn
import matplotlib.pyplot as plt
# any additional libraries would be imported here
data = pandas.read_csv('C:\\Suresh\\Blog Posts\\datasets\\nesarc_pds1134\\SPLITDATA\\CourseData.csv', low_memory=False)
@sureshgorakala
sureshgorakala / PCA using R
Created February 27, 2016 08:16
Data Science using R
library(pca)
data("crimtab") #load data
head(crimtab) #show sample data
dim(crimtab) #check dimensions
str(crimtab) #show structure of the data
sum(crimtab)
colnames(crimtab)
apply(crimtab,2,var) #check the variance accross the variables
pca =prcomp(crimtab) #applying principal component analysis on crimtab data
par(mar = rep(2, 4)) #plot to show variable importance
import nltk
#reading text into python
path = "~/textCourpus.txt"
f = open(path,'r')
lines = [line.replace('\n','') for line in f.readlines()]
#lines2 = [line.replace('\n','') for line in f.readlines()]
type(lines)
len(lines)
@sureshgorakala
sureshgorakala / information_retreival_part1.r
Last active October 24, 2017 05:03
The code shows how to build basic search engine using vector space model in R
#load required pacakges
if(!require("readtext"))
install.packages("readtext")
library(readtext)
if(!require("tm"))
install.packages("tm")
library(tm)
if(!require("stringr"))
@sureshgorakala
sureshgorakala / getting started with RStudio.ipynb
Created December 2, 2017 09:15
getting started with RStudio
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.