This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(mlbench) | |
require(caret) | |
require(MLmetrics) | |
require(plyr) | |
require(ade4) | |
data(Satellite) | |
summary(Satellite) | |
dim(Satellite) | |
my_data <- Satellite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
shinyUI(fluidPage( | |
titlePanel("Self-Organized-Maps"), | |
fluidRow( | |
sidebarPanel( | |
fileInput("file1", "Select CSV:", accept = c("text/csv", "text/comma-separated-values,text/plain", ".csv")), | |
selectInput("sep", label = "Separator", | |
choices = list("Coma" = ",", "Semicolon" = ";", "Tab" = "\t"), | |
selected = 1), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on Manuel Bernal's code | |
######## SOM GENERATOR ########### | |
#Loading Packages needed | |
library(png) # For writePNG function | |
library(kohonen) | |
library(shiny) | |
library(ggplot2) | |
library(jsonlite) | |
library(Hmisc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on Manuel Bernal's code | |
######## SOM GENERATOR ########### | |
#Loading Packages needed | |
library(png) # For writePNG function | |
library(kohonen) | |
library(shiny) | |
library(ggplot2) | |
library(jsonlite) | |
library(Hmisc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(kohonen) | |
library(Hmisc) # useful for multi histogram | |
#loading client data | |
client <- read.csv(file = "C:/Users/eye1/Desktop/Customer Data.csv") | |
#Feature selection | |
data_train <- client[, c("NO_OF_PRODUCTS_6","Balance","LOGIN_DAYS_L3M", "ONLINE_TRANSACTION_L3M")]#data_train <- iris[c(1,2,3,4)] | |
#Explore the data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Hmisc) # useful for multi histogram | |
hist.data.frame(full) # histogram of each variable | |
pairs(full) # pairwise scatter plots | |
data = mx.symbol.Variable('data') | |
fc1 = mx.symbol.FullyConnected(data=data, num_hidden=7) | |
sigm1 = mx.symbol.Activation(data=fc1, act_type="relu") | |
fc2 = mx.symbol.FullyConnected(data=sigm1, num_hidden=2) | |
net = mx.symbol.SoftmaxOutput(data=fc2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(xgboost) | |
library(Matrix) | |
library(data.table) | |
library(vcd) | |
data(Arthritis) | |
df <- data.table(Arthritis, keep.rownames = F) | |
head(df[,AgeDiscret := as.factor(round(Age/10,0))]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(caret) | |
#looking at missing value | |
options(digits=2) | |
stats <- data.frame(missing = sapply(iris, function(x) sum(is.na(x))), | |
mean = sapply(iris, function(x) if(is.numeric(x)) {mean(x, na.rm = T)} else names(table(x)[order(table(x), decreasing = T)])[1]) | |
) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rpart) | |
#Generate binary Target | |
iris$isSetosa <- "N" | |
iris[iris$Species == "setosa",]$isSetosa <- "Y" | |
iris$isSetosa <- as.factor((iris$isSetosa)) | |
levels(iris$isSetosa) <- c("N","Y") | |
head(iris) | |
#Create function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic scatter plot of vocabulary (y) against education (x). Use geom_point() | |
ggplot(Vocab, aes(education, vocabulary))+geom_point() | |
# Use geom_jitter() instead of geom_point() | |
ggplot(Vocab, aes(education, vocabulary))+geom_jitter() | |
# Using the above plotting command, set alpha to a very low 0.2 | |
ggplot(Vocab, aes(education, vocabulary))+geom_jitter(alpha = 0.2) |