knitr::opts_chunk$set(echo = FALSE) library(nnet) library(e1071) library(caret) library(datasets) library(stats)
h6("", tags$img(src ="K.JPG", height= 400, width=400))
Distinguishing/Classifying the different variants of the product based on the features
Eg. Understanding the Product Profile
Predicting the customer choice of a particular product among different products in a product category
Eg. Understanding the Customer Profile
h6("", tags$img(src ="IA.JPG", height= 200, width=400))
h6("", tags$img(src ="IRIS.JPG", height= 400, width=600))
renderUI({ data("iris") dataset = data.frame(iris) set.seed(1) index = runif(nrow(dataset)) dataset = dataset[order(index),] a = split(names(dataset),sapply(dataset, function(x) paste(class(x), collapse=" "))) a = data.frame(a$numeric) selectInput("variablex","Select the variable",choices = a[,1] ,selected = unique(a[,1]) ) }) renderPlot({ data("iris") dataset = data.frame(iris) set.seed(1) index = runif(nrow(dataset)) dataset = dataset[order(index),] attach(dataset) boxplot(get(input$variablex) ~ Species, col = "red")}) inputPanel( downloadButton("downloadPlot", "Download the Plot") ) output$downloadPlot <- downloadHandler( filename = function() { paste("irisplot", ".png", sep = "") }, content = function(file) { png(file) boxplot(get(input$variablex) ~ Species, col = "red",ylab = input$variablex,xlab = "Species") dev.off() })
inputPanel( textAreaInput("model","Enter the model",value = "Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width"), sliderInput("train_num", label = "Enter the proportion of training dataset:", min = 0.6, max = 1, value = 0.6, step = 0.01) ) renderPrint({ data("iris") dataset1 = data.frame(iris) set.seed(1) index = runif(nrow(dataset1)) dataset1 = dataset1[order(index),] prop = input$train_num set.seed(1) dataframe = dataset1 train.rows = sample(row.names(dataframe),dim(dataframe)[1]*prop) dataframet = dataframe[train.rows,] valid.rows = setdiff(row.names(dataframe),train.rows) dataframev = dataframe[valid.rows,] mod = multinom(formula = input$model, data = dataframet,trace = FALSE) print(mod) # print(summary(mod)) # print(round(coefficients(mod),0)) })
h6("", tags$img(src ="PW.JPG", height= 500, width=600))
renderPrint({ data("iris") dataset = data.frame(iris) set.seed(1) index = runif(nrow(dataset)) dataset = dataset[order(index),] prop = input$train_num set.seed(1) dataframe = dataset train.rows = sample(row.names(dataframe),dim(dataframe)[1]*prop) dataframet = dataframe[train.rows,] valid.rows = setdiff(row.names(dataframe),train.rows) dataframev = dataframe[valid.rows,] mod = multinom(input$model, data = dataframet,trace = FALSE) prediction = predict(mod, newdata=dataframev) print(confusionMatrix(dataframev$Species,prediction)) })
inputPanel( numericInput("SL", label = "Sepal Length:",5.1), numericInput("SW", label = "Sepal Width:", 3.5), numericInput("PL", label = "Petal Length:",1.4), numericInput("PW", label = "Petal Width:",0.2) ) renderPrint({ data("iris") dataset = data.frame(iris) set.seed(1) index = runif(nrow(dataset)) dataset = dataset[order(index),] prop = input$train_num set.seed(1) dataframe = dataset train.rows = sample(row.names(dataframe),dim(dataframe)[1]*prop) dataframet = dataframe[train.rows,] valid.rows = setdiff(row.names(dataframe),train.rows) dataframev = dataframe[valid.rows,] mod = multinom(input$model, data = dataframet,trace = FALSE) newdatar = data.frame(Sepal.Length = input$SL, Sepal.Width = input$SW, Petal.Length = input$PL, Petal.Width = input$PW) prediction = predict(mod, newdata= newdatar) cat(sprintf("\nThe predicted flower is %s ",prediction)) predictionp = max(predict(mod, newdata = newdatar, type = "prob")) cat(sprintf("\nThe probability is %f ",predictionp)) })
h6("", tags$img(src ="MP.JPG", height= 400, width=600)) inputPanel( downloadButton("downloadData", "Download the dataset") ) datasetInput <- reactive({ dataset2 = read.csv(system.file("extdata", "MC.csv", package = "MNLR"),header = TRUE) }) output$downloadData <- downloadHandler( filename = function() { paste("ProductChoiceDataset", ".csv", sep = "") }, content = function(file) { write.csv(datasetInput(), file, row.names = FALSE) } )
renderUI({ dataset2 = read.csv(system.file("extdata", "MC.csv", package = "MNLR"),header = TRUE) dataset = dataset2 a = split(names(dataset),sapply(dataset, function(x) paste(class(x), collapse=" "))) a = data.frame(a$integer) selectInput("variablex1","Select the variable",choices = a ) }) renderPlot({ dataset2 = read.csv(system.file("extdata", "MC.csv", package = "MNLR"),header = TRUE) attach(dataset2) assocplot(table(get(input$variablex1),Product),col=c("green","red"))}) inputPanel( downloadButton("downloadPlot2", "Download the Plot") ) output$downloadPlot2 <- downloadHandler( filename = function() { paste("MobileChoiceplot", ".png", sep = "") }, content = function(file) { png(file) dataset2 = read.csv(system.file("extdata", "MC.csv", package = "MNLR"),header = TRUE) attach(dataset2) assocplot(table(get(input$variablex1),Product),col=c("green","red"),xlab = input$variablex1) dev.off() })
inputPanel( textAreaInput("model1","Enter the model",value = "Product ~ ."), sliderInput("train_num1", label = "Enter the proportion of training dataset:", min = 0.6, max = 1, value = 0.6, step = 0.01), sliderInput("is", label = "Enter Income Status : 1 for High and 0 for Low", min = 0, max = 1, value = 1, step = 1), sliderInput("se", label = "Enter Selfie Enthusiast : 1 for Yes and 0 for No", min = 0, max = 1, value = 1, step = 1) ) renderPrint({ dataset2 = read.csv(system.file("extdata", "MC.csv", package = "MNLR"),header = TRUE) prop = input$train_num1 set.seed(1) dataframe = dataset2 train.rows = sample(row.names(dataframe),dim(dataframe)[1]*prop) dataframet = dataframe[train.rows,] valid.rows = setdiff(row.names(dataframe),train.rows) dataframev = dataframe[valid.rows,] mod = multinom(input$model1, data = dataframet,trace = FALSE) newdatar = data.frame(IncomeStatus = input$is,SelfieEnthusiast = input$se) prediction = predict(mod, newdata= newdatar) cat(sprintf("\nThe predicted Mobile Phone Product is %s ",prediction)) predictionp = max(predict(mod, newdata = newdatar, type = "prob")) cat(sprintf("\nThe probability is %f ",predictionp)) })
Used for profiling risk of different types of products(especially harmful)
Used for validating the customer segments or product variants after clustering technique
Development of score cards based on the computation of probability
Used for profiling behavioral risk of customers/subjects
inputPanel( #, fileInput("file", "Upload the *.csv file with headers"), textAreaInput("model2", "Enter the model") ) renderPrint({ file1 = input$file if(is.null(file1)){return()} data = read.table(file = file1$datapath,sep =",",header = TRUE) if(is.null(data())){return()} print(head(data,1)) }) renderPrint({ file1 = input$file if(is.null(file1)){return()} data = read.table(file = file1$datapath,sep =",",header = TRUE) if(is.null(data())){return()} datai = data.frame(data) mod2 = multinom(formula = input$model2, data = datai,trace = FALSE) print(mod2) })
h6("", tags$img(src ="RS.JPG", height= 500, width=600)) inputPanel( downloadButton("downloadCode", "Download the Rcode") ) datasetInput2<- reactive({ dataset3 = read.csv(system.file("extdata", "multinom.txt", package = "MNLR")) }) output$downloadCode <- downloadHandler( filename = function() { paste("RCode", ".R", sep = "") }, content = function(file) { write.csv(datasetInput2(), file,row.names = FALSE,fileEncoding = "") })
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.