Code Monkey home page Code Monkey logo

modeldown_example's Introduction

modelDown ShowCase

Examples for modelDown

Classification for RMS Titanic data

A use case for 4 different classification models with 7 features: 4 numerical and 3 categorical.

Find the website here: https://mi2datalab.github.io/modelDown_example/

Here is the script:

# Prepare the data
library("DALEX")
titanic <- na.omit(titanic)

# Random Forest model
library("randomForest")
model_titanic_rf <- randomForest(survived == "yes" ~ gender + age + class + embarked +
                                   fare + sibsp + parch,  data = titanic[,-5])
explain_titanic_rf <- explain(model_titanic_rf, 
                              data = titanic[,-c(9,5)],
                              y = titanic$survived == "yes", 
                              label = "Random Forest v7")

# SVM model
library("e1071")
model_titanic_svm <- svm(survived == "yes" ~ class + gender + age + sibsp +
                           parch + fare + embarked, data = titanic[,-5], 
                         type = "C-classification", probability = TRUE)
explain_titanic_svm <- explain(model_titanic_svm, data = titanic[,-c(9,5)], 
                               y = titanic$survived == "yes", 
                               label = "Support Vector Machines")

# GBM model
library("gbm")
model_titanic_gbm <- gbm(survived == "yes" ~ class + gender + age + sibsp +
                           parch + fare + embarked, data = titanic[,-5], n.trees = 15000)
explain_titanic_gbm <- explain(model_titanic_gbm, data = titanic[,-c(9,5)], 
                               y = titanic$survived == "yes", 
                               predict_function = function(m,x) predict(m, x, n.trees = 15000, type = "response"),
                               label = "Generalized Boosted Models")

# k-NN model

library("caret")
model_titanic_knn <- knn3(survived == "yes" ~ class + gender + age + sibsp +
                            parch + fare + embarked, data = titanic[,-5], k = 5)
explain_titanic_knn <- explain(model_titanic_knn, data = titanic[,-c(9,5)], 
                               y = titanic$survived == "yes", 
                               predict_function = function(m,x) predict(m, x)[,2],
                               label = "k-Nearest Neighbours")


# Website generation
modelDown(explain_titanic_rf, explain_titanic_gbm, 
          explain_titanic_svm, explain_titanic_knn,
  device = "svg",
  remote_repository_path = "MI2DataLab/modelDown_example/docs",
  output_folder = "modelDown_Titanic_example")

modeldown_example's People

Contributors

pbiecek avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.