-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
204 lines (167 loc) · 13.8 KB
/
app.R
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
library(readr)
library(dplyr)
library(shiny)
library(superml)
library(shinydashboard)
library(randomForest)
options(warn=-1)
model = readRDS("model.rds")
ui = dashboardPage(
dashboardHeader(
title = "A Fine Windy Day",
dropdownMenu(type = "message",
messageItem(from = "Siddharth", message = "Hey! Welcome To The Dashboard.", time = "Today"),
messageItem(from = "Siddharth", message = "Check the Windmill Power Predictor!", time = "Today"),
icon = icon('comment'))
),
skin = "purple",
dashboardSidebar(
sidebarMenu(
menuItem("Visuals Dashboard", tabName = "dashboard", icon = icon("bar-chart-o")),
menuItem("Power Predictor", tabName = "form", icon = icon("table"), badgeLabel = "new", badgeColor = "green"),
menuItem("About Project", tabName = "about", icon = icon("code-fork"))
)
),
dashboardBody(
tabItems(
tabItem(tabName = "dashboard",
fluidRow(style = 'margin: 10px;',
box(align = "center", solidHeader = T, status = "primary",
column(width = 12, img(src = "gif1.gif", width = '100%'))),
box(align = "center", solidHeader = T, status = "primary",
column(width = 12, img(src = "gif2.gif", width = '100%')))
),
fluidRow(style = 'margin: 25px;',
box(width = '100%', solidHeader = T, status = "warning", style = "padding: 15px",
tags$body(HTML(
"
<div class='tableauPlaceholder' id='viz1650895231198' style='position: relative'>
<noscript>
<a href='#'>
<img alt='Windmill Analytics Dashboard ' src='https://public.tableau.com/static/images/Wi/WindmillPowerPrediction/WindmillAnalyticsDashboard/1_rss.png' style='border: none' />
</a>
</noscript>
<object class='tableauViz' style='display:none;'>
<param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' />
<param name='embed_code_version' value='3' />
<param name='site_root' value='' />
<param name='name' value='WindmillPowerPrediction/WindmillAnalyticsDashboard' />
<param name='tabs' value='no' />
<param name='toolbar' value='yes' />
<param name='static_image' value='https://public.tableau.com/static/images/Wi/WindmillPowerPrediction/WindmillAnalyticsDashboard/1.png' />
<param name='animate_transition' value='yes' />
<param name='display_static_image' value='yes' />
<param name='display_spinner' value='yes' />
<param name='display_overlay' value='yes' />
<param name='display_count' value='yes' />
<param name='language' value='en-US' />
</object>
</div>
<script type='text/javascript'>
var divElement = document.getElementById('viz1650895231198');
var vizElement = divElement.getElementsByTagName('object')[0];
if (divElement.offsetWidth > 800) {
vizElement.style.width='100%';
vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
}
else if (divElement.offsetWidth > 500) {
vizElement.style.width='100%';
vizElement.style.height=(divElement.offsetWidth*0.75)+'px';
}
else {
vizElement.style.width='100%';
vizElement.style.height='1327px';
}
var scriptElement = document.createElement('script');
scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js';
vizElement.parentNode.insertBefore(scriptElement, vizElement);
</script>
"
))
)
)
), # End of Item Tab 1
tabItem(tabName = "form",
fluidRow(style = 'margin: 50px;', align = 'center',
box(width = '100%',
h2("Windmill Power Predictor", align = 'center', style = "padding: 10px; font-family: Georgia, serif; font-size: 30px; color:black"),
solidHeader = T, status = "warning")
),
fluidRow(style = 'margin: 50px;',
column(width = 12, align = "center",
box(selectInput(inputId = "month", label = "Month", c(1:12)), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(selectInput(inputId = "day", label = "Day", c(1:31)), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "wind_speed", label = "Wind Speed (m/s) (21.23 to 95.25)"), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "atmospheric_temperature",label = "Atmospheric Temperature (C) (10.10 to 22.57)"), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "shaft_temperature", label = "Shaft Temperature (C) (41.85 to 45.67)"), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "blades_angle", label = "Blade Angle (Deg) (-146.260 to 165.169)"), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "gearbox_temperature", label = "Gearbox Temperature (C) (40.56 to 45.87)"), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "engine_temperature", label = "Engine Temperature (C) (41.912 to 45.169)"), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "motor_torque", label = "Motor Torque (N-m) (870 to 2460.9)"), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "atmospheric_pressure", label = "Atmospheric Pressure (Pas) (16891 to 116412)"), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "area_temperature", label = "Area Temperature (C) (27.33 to 55)"), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "windmill_body_temperature", label = "Windmill Body Temperature (C) (20.77 to 44.32)"), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "wind_direction", label = "Wind Direction (Deg) (247.4137 to 331.624)"), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "resistance", label = "Resistance (ohm) (1268 to 1828)"), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;"),
box(selectInput(inputId = "turbine_status", label = "Turbine Status", c("A", "A2", "AAA", "AB", "ABC", "AC", "B", "B2", "BA", "BB", "BBB", "BCB", "BD", "D")), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;"),
box(selectInput(inputId = "cloud_level", label = "Cloud Level", c("Extremely Low", "Low", "Medium")), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "blade_length", label = "Blade Length (m) (2.249 to 18.21)"), solidHeader = T, status = "warning", style = "padding: 12px; font-family: Times New Roman;"),
box(textInput(inputId = "blade_breadth", label = "Blade Breadth (m) (0.2007 to 0.5000)"), solidHeader = T, status = "primary", style = "padding: 12px; font-family: Times New Roman;")
)
),
fluidRow(style = 'margin: 50px;', align = 'center',
box(width = '100%', style = "padding: 20px;", solidHeader = T, status = "primary",
actionButton(inputId = "submit", label = "Submit", icon("paper-plane"), class = "btn btn-warning"))
),
fluidRow(style = 'margin: 50px;', align = 'center',
box(width = '100%', style = "padding: 5px;", solidHeader = T, status = "warning",
valueBoxOutput(outputId = "power", width = 12))
)
), # End of Tab Item 2
tabItem(tabName = "about",
fluidRow(style = 'margin: 25px;',
box(width = '100%', solidHeader = T, status = "warning",
h2("Project Workflow", align = 'center', style = "font-family: Georgia, serif; font-size: 30px; color:black"),
img(src = "Overview.png", width = '100%'))
),
fluidRow(style = 'margin: 25px;',
box(width = '100%', solidHeader = T, status = "warning",
img(src = "Certificate.jpg", width = '100%'))
)
) # End of Tab Item 3
) # End of Tab Items
) # End of Dashboard Body
) # End of Dashboard Page
server = function(input, output){
user_prediction = reactive({
df = data.frame(
month = as.numeric(input$month),
day = as.numeric(input$day),
wind_speed = as.numeric(input$wind_speed),
atmospheric_temperature = as.numeric(input$atmospheric_temperature),
shaft_temperature = as.numeric(input$shaft_temperature),
blades_angle = as.numeric(input$blades_angle),
gearbox_temperature = as.numeric(input$gearbox_temperature),
engine_temperature = as.numeric(input$engine_temperature),
motor_torque = as.numeric(input$motor_torque),
atmospheric_pressure = as.numeric(input$atmospheric_pressure),
area_temperature = as.numeric(input$area_temperature),
windmill_body_temperature = as.numeric(input$windmill_body_temperature),
wind_direction = as.numeric(input$wind_direction),
resistance = as.numeric(input$resistance),
turbine_status = as.character(input$turbine_status),
cloud_level = as.character(input$cloud_level),
blade_length = as.numeric(input$blade_length),
blade_breadth = as.numeric(input$blade_breadth))
df$cloud_level = as.numeric(factor(df$cloud_level, levels = c("Extremely Low", "Low", "Medium")))
label = LabelEncoder$new()
df$turbine_status = label$fit_transform(df$turbine_status)
op = round(predict(model, df), digits = 3)
valueBox(op, "Power Generated (kW/h)")
}) # End of Dataset Input Function
output$power = renderValueBox({
validate(need(input$submit!=0, "Enter Details And Press Submit !"))
isolate(user_prediction())
})
} # End of Shiny Server
shinyApp(ui, server)