Skip to content

stackOcean-official/shinify

Repository files navigation

shinify

No more coding needed, just add one line to your script in which you call our magic shinify function.

Shinify automatically creates a shiny server and visual interface for you to interact with your machine learning or statistical model.

⚠️ This repository is still in an early stage of development and the functions are limited. We are constantly working on adding new models and packages to support with shinify. Take a look in the jumpstart folder for currently supported models and libraries. We love the open source community and want to show what we are working on early. We will update this readme with more information. Until then, feel free to share your thoughts, contact us, and contribute if you'd like.


How to use

Install the package from GitHub (If you don't have devtools, install it first: install.packages("devtools")):

devtools::install_github("stackOcean-official/shinify")

In your code load the shinify package and after that, just hand your model over to our shinify function to start a R Shiny server and let shinify figure out all the configuration.

# load shinify package
library(shinify)

# do your logistic regression or other algorithms
log_reg <- glm(...)

# let shinify transform it into a shiny server
shinify(log_reg)

shinify-example

Here is the full example for a logistic regression. You can find more examples in the jumpstart folder :

library(shinify)

# load data
data <- read.csv("https://github.com/stackOcean-official/hostr/files/9681827/pokemon.csv")

# create variables
legendary <- data$is_legendary
attack <- data$attack
defense <- data$defense

# split train and test data
data <- data.frame(legendary, attack, defense)
data_train <- data[1:(nrow(data) - 100), ]
data_test <- data[(nrow(data) - 99):nrow(data), ]

# actual logistic regression
log_reg <- glm(legendary ~ attack + defense, data = data_train, family = binomial())
summary(log_reg)

# input for new prediction
attack <- 120
defense <- 290
test_data_new <- data.frame(attack, defense)

# definition of a sigmoid function to normalize predictions
sigmoid <- function(x) {
  result <- exp(x) / (1 + exp(x))
  return(result)
}

# actual predicted percentage that pokemon is legendary with glm model
sigmoid(predict(log_reg, test_data_new))

# shinify logistic model
shinify(log_reg, modeltype = "log_reg", app_title = "your title here")

Note that you can only host one model at a time in the current development status.


After calling the shinify() method with the model, a shiny server is started where you can interact with your own model via a graphical interface. shiny-server-preview

Shinify function in detail

The shinify() function creates a shiny server for your model

Prop Type Required Default Description
model model yes "" Your R model (output from statistics / machine learning algorithm)
modeltype string no "" Abbreviation of your model type that determines. See table below for possible configuration
variables vector no c() Set name of input variables your model is expecting for prediction. Optional if your model has 'model$terms' attribute.
variable_types vector no c() Set type of input variables your model is expecting for prediction. Optional if your model has 'model$terms' attribute.
csv_upload boolean no FALSE Set TRUE if you want to upload a CSV file as input.
app_title string no "Welcome to shinify" Add a Headline to your shiny server.
app_theme string no "lumen" Set the shiny theme you want to use.
input_labels vector no c() Set displayed name of your input variables. Does not effect the name of your input variables used in prediction.
output_label string no "" Set displayed name of your output variable. Does not effect the name of your output variable used in prediction.
default_input_values vector no c() Set default values for your input variables when starting the shiny server.

These are the currently available options for modeltype. We are constantly working on adding new models and packages to support with shinify. Please write an issue if your modeltype is missing 💪

modeltype name of algorithm
dt_party Decision Tree Party
dr_rpart Decision Tree rpart
knn k Nearest Neighbors
lin_reg Linear Regression
log_reg Logistic Regression
svm Support Vector Machine
rf Random Forest

Here are some examples how to call the shinify function:

# just call shinify with a simple model
shinify(model)

# call shinify with a log_reg modeltype and the title "awesome discovery" in the shiny app
shinify(model, modeltype="log_reg", app_title = "awesome discovery")

# call shinify with a svm modeltype and labels for input values
shinify(model, modeltype="svm", app_title = "your awesome title", input_labels = c("Attack Value", "Defense Value"))

# call shinify with a model that has no model$terms
shinify(model, "dt_party", variables = c("attack", "defense"), variable_types = c("numeric", "numeric"))

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some AmazingFeature')
  5. Push to the branch (git push origin feature/AmazingFeature)
  6. Open a pull request

License

Distributed under the MIT License. See LICENSE for more information.

About

Creates a shiny server to interact with your machine learning model - no further coding needed.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages