Modul klastering

clusteringedit analisa-cluster

Program di

https://github.com/kungfumas/stbi/blob/master/pamabstrak.R

data

https://github.com/kungfumas/stbi/blob/master/abstraks.zip

 

https://github.com/kungfumas/stbi/blob/master/kmeansdata.R

Posted in Data warehouse dan data mining, Information Retrieval, Lecture Notes | Leave a comment

Hirarki klastering twitter menggunakan R

install.packages(“twitteR”)
install.packages(“ROAuth”)
install.packages(“tm”)
install.packages(“ggplot2”)
install.packages(“wordcloud”)
install.packages(“plyr”)
install.packages(“RTextTools”)

install.packages(“e1071”)

library(e1071)

library(twitteR)
library(ROAuth)
library(tm)
library(ggplot2)
library(wordcloud)
library(plyr)
library(RTextTools)
library(e1071)

setup_twitter_oauth(“consumer key”, “consumer secret key”, “access token”,”access token key”)

tweets <- userTimeline(“Trump”, n = 10)
n.tweet <- length(tweets)
# convert tweets to a data frame
tweets.df <- twListToDF(tweets)

myCorpus <- Corpus(VectorSource(tweets.df$text))
# convert to lower case
myCorpus <- tm_map(myCorpus, content_transformer(tolower))
# remove URLs
removeURL <- function(x) gsub(“http[^[:space:]]*”, “”, x)
myCorpus <- tm_map(myCorpus, content_transformer(removeURL))
# remove anything other than English letters or space
removeNumPunct <- function(x) gsub(“[^[:alpha:][:space:]]*”, “”, x)
myCorpus <- tm_map(myCorpus, content_transformer(removeNumPunct))
# remove stopwords
myStopwords <- c(setdiff(stopwords(‘english’), c(“r”, “big”)),”use”, “see”, “used”, “via”, “amp”)
myCorpus <- tm_map(myCorpus, removeWords, myStopwords)
# remove extra whitespace
myCorpus <- tm_map(myCorpus, stripWhitespace)
# keep a copy for stem completion later
myCorpusCopy <- myCorpus
myCorpus
term.freq <- rowSums(as.matrix(tdm))
tdm <- TermDocumentMatrix(myCorpus)
tdmat <- as.matrix(removeSparseTerms(tdm, sparse=0.3))
# compute distances
distMatrix <- dist(scale(tdm))
fit <- hclust(distMatrix, method=”ward.D2″)
plot(fit)
fit <- hclust(distMatrix, method=”single”)
plot(fit)

Posted in Information Retrieval, Lecture Notes | Leave a comment

web service facebook4j

Pelajari

http://facebook4j.github.io/en/index.html

http://stackoverflow.com/questions/20125895/getting-posts-from-a-page-using-facebook4j-api

http://www.programcreek.com/java-api-examples/index.php?api=facebook4j.auth.AccessToken

 

Posted in Lecture Notes, Web Service | Leave a comment

Pemrograman Twitter

Cobalah program ini

https://github.com/kungfumas/webservice/blob/master/NamexTweet.java

http://140dev.com/download/javascript_ebook.pdf

 

Posted in Lecture Notes, Web Service | Leave a comment

Program R untuk menampilkan wordcloud timeline Twitter

//https://www.youtube.com/watch?v=cdgUtSUxvyQ

install.packages(“twitteR”)
install.packages(“ROAuth”)
install.packages(“tm”)
install.packages(“ggplot2”)
install.packages(“wordcloud”)

library(twitteR)
library(ROAuth)
library(tm)
library(ggplot2)
library(wordcloud)
setup_twitter_oauth(“consumer_key”, “cosumer_secret_key”, “access_token_key”,”access_token_secret_key”)

tweets <- userTimeline(“Banjir”, n = 50)
n.tweet <- length(tweets)
# convert tweets to a data frame
tweets.df <- twListToDF(tweets)

myCorpus <- Corpus(VectorSource(tweets.df$text))
# convert to lower case
myCorpus <- tm_map(myCorpus, content_transformer(tolower))
# remove URLs
removeURL <- function(x) gsub(“http[^[:space:]]*”, “”, x)
myCorpus <- tm_map(myCorpus, content_transformer(removeURL))
# remove anything other than English letters or space
removeNumPunct <- function(x) gsub(“[^[:alpha:][:space:]]*”, “”, x)
myCorpus <- tm_map(myCorpus, content_transformer(removeNumPunct))
# remove stopwords
myStopwords <- c(setdiff(stopwords(‘english’), c(“r”, “big”)),”use”, “see”, “used”, “via”, “amp”)
myCorpus <- tm_map(myCorpus, removeWords, myStopwords)
# remove extra whitespace
myCorpus <- tm_map(myCorpus, stripWhitespace)
# keep a copy for stem completion later
myCorpusCopy <- myCorpus

tdm <- TermDocumentMatrix(myCorpus)

term.freq <- rowSums(as.matrix(tdm))

term.freq <- subset(term.freq, term.freq >= 20)
df <- data.frame(term = names(term.freq), freq = term.freq)

ggplot(df, aes(x=term, y=freq)) + geom_bar(stat=”identity”) +
xlab(“Terms”) + ylab(“Count”) + coord_flip() +
theme(axis.text=element_text(size=7))

m <- as.matrix(tdm)
# calculate the frequency of words and sort it by frequency
word.freq <- sort(rowSums(m), decreasing = T)
# colors
pal <- brewer.pal(9, “BuGn”)[-(1:4)]

# plot word cloud

wordcloud(words = names(word.freq), freq = word.freq, min.freq = 3,
random.order = F, colors = pal)

Posted in Information Retrieval, Lecture Notes | Leave a comment

How to Insert JSON Data into MySQL using PHP

http://www.kodingmadesimple.com/2014/12/how-to-insert-json-data-into-mysql-php.html

Posted in Lecture Notes, Web Service | Leave a comment

Proyek Ujian Tengah Semester

Menggunakan basisdata https://github.com/kungfumas/webservice/blob/master/akademik.sql buatlah program Rest web service  berbasis web dan aplikasi android untuk menambah data mahasiswa dan menampilkan data mahasiswa.

Posted in Lecture Notes, Web Service | Leave a comment