File size: 8,414 Bytes
f17cc6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#
# This is the user-interface definition of a Shiny web application. You can
# run the application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
#    http://shiny.rstudio.com/
#

shinyUI(fluidPage(
  #theme = shinythemes::shinytheme("cerulean"),
  # Application title
  titlePanel("DeepVATS"),
  
  # Load Shinyjs
  shinyjs::useShinyjs(),
  
  # Sidebar with a slider input for number of bins
  sidebarLayout(
    sidebarPanel(
      fluidRow(
        shiny::actionButton("load_dataset", label = "Load dataset", icon = icon("database")),
        shiny::actionButton("load_embs", label = "Load embeddings", icon = icon("project-diagram"))
      ),
      hr(),
      selectizeInput("dataset", label = "Dataset", choices = NULL),
      selectizeInput("encoder", label = "Encoder", choices = NULL),
      #selectizeInput("embs_ar", label = "Select embeddings", choices = names(embs_l)),
      br(),
      sliderInput("wlen", "Select window size", min = 0, max = 0, value =0 , step = 1),
      sliderInput("stride", "Select stride", min = 0, max = 0, value = 0, step = 1),
      # sliderInput("points_emb", "Select range of points to plot in the projections", 
      #             min = 0, max = 0, value = 0, step = 1, ticks = FALSE),
      #uiOutput("points_prj_controls"),
      #### TODO: Check. Added for debugging solar 4_secs
      sliderInput("prj_n_neighbors", "Projections n_neighbors:", min = 1, max = 50, value = 15),
      sliderInput("prj_min_dist", "Projections min_dist:", min = 0.0001, max = 1, value = 0.1),
      #sliderInput("prj_random_state", "Projections random_state:", min = 0, max = 2^32-1, value = 1234),
      sliderInput("prj_random_state", "Projections random_state:", min = 0, max = 2000, value = 1234),
      ################
      radioButtons("cpu_flag", "Use: ", c("GPU", "CPU"), selected = "GPU", inline = T),
      radioButtons("dr_method", "Projection method:", c("UMAP", "TSNE", "PCA"), selected="UMAP", inline=T),
      br(),
      radioButtons("clustering_options", label = "Select a clustering option", selected = "no_clusters",
                   choices = c("No clusters" = "no_clusters",
                               #"Show precomputed clusters" = "precomputed_clusters",
                               "Calculate and show clusters" = "calculate_clusters")),
      # conditionalPanel(
      #     condition = "input.clustering_options == 'precomputed_clusters'",
      #     selectInput("clusters_labels_name", label = "Select a clusters_labels artifact", choices = NULL),
      #     tags$b("Selected 'clusters_labels' artifact description:"),
      #     textOutput("clusters_labels_ar_desc")
      # ),
      conditionalPanel(
          condition = "input.clustering_options == 'calculate_clusters'",
        selectInput("metric_hdbscan", label = "Metric", choices = DEFAULT_VALUES$metric_hdbscan),
        sliderInput("min_cluster_size_hdbscan", label = "min_cluster_size_hdbscan", 
                    value = DEFAULT_VALUES$min_cluster_size_hdbscan, min=0, max=200, step = 1),
        sliderInput("min_samples_hdbscan", label = "min_samples_hdbscan", 
                    value = DEFAULT_VALUES$min_samples_hdbscan, min=0, max=50, step = 1),
        sliderInput("cluster_selection_epsilon_hdbscan", label = "cluster_selection_epsilon", 
                    value = DEFAULT_VALUES$cluster_selection_epsilon_hdbscan, min=0, max=5, step = 0.01),
        actionBttn(inputId = "calculate_clusters", label = "Calculate and show clusters", style = "bordered",
                   color = "primary", size = "sm", block = TRUE)
      ),
    ),
    # Show a plot of the generated distribution
    mainPanel(
      tabsetPanel(
        id = "tabs",
        tabPanel(
          "Projections",
          fluidRow(
            h3("Embedding projections"),
            fluidRow(
              column(1,
                     dropdownButton(
                       tags$b("Set height of the projections plot (px):"),
                       numericInput("embedding_plot_height", label = "Height",value =400),
                       hr(),
                       tags$b("Configure aestethics"),
                       sliderInput("path_line_size", label = "path_line_size", 
                                   value = DEFAULT_VALUES$path_line_size, min=0, max=5, step = 0.01),
                       sliderInput("path_alpha", label = "path_alpha",
                                   value = DEFAULT_VALUES$path_alpha, min=0, max=1, step = 0.01),
                       sliderInput("point_alpha", label = "point_alpha",
                                   value = DEFAULT_VALUES$point_alpha, min=0, max=1, step = 0.01),
                       sliderInput("point_size", label = "point_size",
                                   value = DEFAULT_VALUES$point_size, min=0, max=10, step = 0.5),
                       checkboxInput("show_lines", "Show lines", value = TRUE),
                       actionButton('savePlot', 'Save embedding projections plot'),

                       actionBttn(inputId = "update_prj_graph",label = "Update aestethics",style = "simple",
                                  color = "primary",icon = icon("bar-chart"),size = "xs", block = TRUE),
                       circle = FALSE, status = "primary",
                       icon = icon("gear"), width = "300px",size = "xs",
                       tooltip = tooltipOptions(title = "Configure the embedding appearance"),
                       inputId = "projections_config"
                     )
              ),
              column(8,
                     prettyToggle(
                       inputId = "zoom_btn",
                       label_on = "Zoom out",
                       label_off = "Zoom in",
                       shape = "square",
                       outline = TRUE,
                       plain = TRUE,
                       inline = TRUE,
                       icon_on = icon("search-minus"), 
                       icon_off = icon("search-plus"),
                       status_on = "danger",
                       status_off = "primary"
                     ),
                     materialSwitch(
                       inputId = "plot_windows",
                       label = "Plot windows",
                       status = "info",
                       value = TRUE,
                       inline = TRUE
                     )
              ),
              column(3)
            ),
            fluidRow(
              uiOutput("projections_plot_ui")
            )
          ),
          fluidRow(h3("Original data")),
          fluidRow(
            dropdownButton(
              tags$b("Select/deselect variables"),
              tags$div(style= 'height:200px; overflow-y: scroll', 
                       checkboxGroupInput(inputId = "select_variables",
                                          label=NULL, choices = NULL, selected = NULL)
              ),
              actionBttn(inputId = "selectall",label = "Select/Deselect all",style = "simple",
                         color = "primary",icon = icon("check-double"),size = "xs", block = TRUE),
              hr(),
              prettySwitch(inputId = "dygraph_sel",label = "Show stacked graphs (Not available yet)",
                           status = "success",fill = TRUE),
              circle = FALSE, status = "primary", size = "xs",
              icon = icon("gear"), width = "300px",
              tooltip = tooltipOptions(title = "Configure the TS appearance"),
              inputId = "ts_config"
            )
          ),
          fluidRow(
            column(12,
              #sliderInput(
                #"nrows", "Select initial data range:", 
                #min = 0, max = 10000, 
                #value = c(0,0),
                #step = 1000000
              #),
              dygraphOutput("ts_plot_dygraph") %>% withSpinner(),
              plotOutput("windows_plot"),
              uiOutput("windows_text")
            )
          )
          #verbatimTextOutput("projections_plot_interaction_info"),
          #verbatimTextOutput("point")
          
        ),
        tabPanel(
          "Information",
          fluidRow(
            h3("Time series"),
            dataTableOutput("ts_ar_info"),
            h3("Configuration of the associated encoder"),
            dataTableOutput("enc_info")
          )
        ),
      )
    )
  )

  
))