Download app.R from jameson-bodenburg/Analytics_Methodologies: direct link, hf CLI and curl.
- Browser
- Download file 3.17 kB
-
https://huggingface.co/spaces/jameson-bodenburg/Analytics_Methodologies/resolve/main/app.R
- Command line
-
hf download hf://spaces/jameson-bodenburg/Analytics_Methodologies/app.R
-
curl -L -o app.R https://huggingface.co/spaces/jameson-bodenburg/Analytics_Methodologies/resolve/main/app.R
3.17 kB
| library(shiny) | |
| library(DT) | |
| # --- Mock Data --- | |
| model_data <- data.frame( | |
| Methodology = c( | |
| "Linear Regression", | |
| "Logistic Regression", | |
| "Random Forest", | |
| "Gradient Boosting (XGBoost)", | |
| "Support Vector Machine", | |
| "Neural Network (MLP)", | |
| "K-Nearest Neighbors", | |
| "LASSO Regression", | |
| "Decision Tree", | |
| "Naive Bayes" | |
| ), | |
| Category = c( | |
| "Regression", "Classification", "Ensemble", "Ensemble", | |
| "Kernel-based", "Deep Learning", "Instance-based", | |
| "Regression", "Tree-based", "Probabilistic" | |
| ), | |
| Interpretability = c( | |
| "High", "High", "Medium", "Low", | |
| "Low", "Low", "Medium", | |
| "High", "High", "High" | |
| ), | |
| Scalability = c( | |
| "High", "High", "Medium", "High", | |
| "Low", "High", "Low", | |
| "High", "Medium", "High" | |
| ), | |
| Handles_Nonlinearity = c( | |
| "No", "No", "Yes", "Yes", | |
| "Yes", "Yes", "Yes", | |
| "No", "Yes", "No" | |
| ), | |
| Typical_Use_Case = c( | |
| "Continuous outcome prediction", | |
| "Binary/multi-class classification", | |
| "Tabular data, feature importance", | |
| "Competitions, structured data", | |
| "High-dimensional classification", | |
| "Complex pattern recognition", | |
| "Recommendation, anomaly detection", | |
| "Feature selection, sparse models", | |
| "Simple rule-based decisions", | |
| "Text classification, spam filtering" | |
| ), | |
| Requires_Feature_Scaling = c( | |
| "No", "No", "No", "No", | |
| "Yes", "Yes", "Yes", | |
| "No", "No", "No" | |
| ), | |
| stringsAsFactors = FALSE | |
| ) | |
| # --- UI --- | |
| ui <- fluidPage( | |
| titlePanel("Model / Methodology Comparison"), | |
| sidebarLayout( | |
| sidebarPanel( | |
| width = 3, | |
| h4("Filters"), | |
| selectInput( | |
| "category_filter", "Category:", | |
| choices = c("All", sort(unique(model_data$Category))), | |
| selected = "All" | |
| ), | |
| selectInput( | |
| "interp_filter", "Interpretability:", | |
| choices = c("All", "High", "Medium", "Low"), | |
| selected = "All" | |
| ), | |
| checkboxInput("nonlinear_only", "Only models handling nonlinearity", FALSE), | |
| hr(), | |
| p("This table summarizes key properties of common modeling methodologies.", | |
| style = "color: grey; font-size: 0.9em;") | |
| ), | |
| mainPanel( | |
| width = 9, | |
| DTOutput("model_table") | |
| ) | |
| ) | |
| ) | |
| # --- Server --- | |
| server <- function(input, output, session) { | |
| filtered_data <- reactive({ | |
| df <- model_data | |
| if (input$category_filter != "All") { | |
| df <- df[df$Category == input$category_filter, ] | |
| } | |
| if (input$interp_filter != "All") { | |
| df <- df[df$Interpretability == input$interp_filter, ] | |
| } | |
| if (input$nonlinear_only) { | |
| df <- df[df$Handles_Nonlinearity == "Yes", ] | |
| } | |
| df | |
| }) | |
| output$model_table <- renderDT({ | |
| datatable( | |
| filtered_data(), | |
| options = list( | |
| pageLength = 10, | |
| autoWidth = TRUE, | |
| columnDefs = list( | |
| list(width = "180px", targets = 0), | |
| list(width = "200px", targets = 5) | |
| ) | |
| ), | |
| rownames = FALSE, | |
| colnames = c( | |
| "Methodology", "Category", "Interpretability", "Scalability", | |
| "Handles Nonlinearity", "Typical Use Case", "Requires Feature Scaling" | |
| ) | |
| ) | |
| }) | |
| } | |
| shinyApp(ui, server) |