Analysis save energy by building good model based on human comfort and other factors Use data Smart WiFi Thermostat Enabled Thermal Comfort Control in Residences
library(readr)
dt <- read_csv("d:/FREELANCE-USA/Additional resources for project/R Scripts/DF21.csv")
#dim(dt) #[1] 14041 16
dt <- dt[,-c(1:5)]
sum(is.na(dt)) #[1] 6
## [1] 6
dt1 <- na.omit(dt) #[1] 14035 11 OK
library(h2o)
h2o.init()
##
## H2O is not running yet, starting it now...
##
## Note: In case of errors look at the following log files:
## C:\Users\Asus\AppData\Local\Temp\RtmpKYmJig\filee988bf1f28/h2o_Asus_started_from_r.out
## C:\Users\Asus\AppData\Local\Temp\RtmpKYmJig\filee98599c299/h2o_Asus_started_from_r.err
##
##
## Starting H2O JVM and connecting: ..... Connection successful!
##
## R is connected to the H2O cluster:
## H2O cluster uptime: 24 seconds 789 milliseconds
## H2O cluster timezone: Asia/Bangkok
## H2O data parsing timezone: UTC
## H2O cluster version: 3.32.0.1
## H2O cluster version age: 6 months and 26 days !!!
## H2O cluster name: H2O_started_from_R_Asus_zoz647
## H2O cluster total nodes: 1
## H2O cluster total memory: 0.79 GB
## H2O cluster total cores: 2
## H2O cluster allowed cores: 2
## H2O cluster healthy: TRUE
## H2O Connection ip: localhost
## H2O Connection port: 54321
## H2O Connection proxy: NA
## H2O Internal Security: FALSE
## H2O API Extensions: Amazon S3, Algos, AutoML, Core V3, TargetEncoder, Core V4
## R Version: R version 4.0.3 (2020-10-10)
h2o.no_progress()
dt1 <- as.h2o(dt1)
splits <- h2o.splitFrame(dt1, ratios = 0.8, seed = 1)
train <- splits[[1]]
test <- splits[[2]]
# data mumming
y <- "Cool.Demand.Status"
# Run AutoML for 1 minute # time adj.
aml <- h2o.automl(y = y,
training_frame = train,
leaderboard_frame = test,
max_runtime_secs = 30,
seed = 1)#,
##
## 04:54:55.530: AutoML: XGBoost is not available; skipping it.
#project_name = "model_aml")
#aml <- h2o.automl(y = y, training_frame = train, max_runtime_secs = 30, seed = 1)
exa <- h2o.explain(aml, test)
exa
##
##
## Leaderboard
## ===========
##
## > Leaderboard shows models with their metrics. When provided with H2OAutoML object, the leaderboard shows 5-fold cross-validated metrics by default (depending on the H2OAutoML settings), otherwise it shows metrics computed on the newdata. At most 20 models are shown by default.
##
##
## | | model_id | mean_residual_deviance | rmse | mse | mae | rmsle | training_time_ms | predict_time_per_row_ms
## |:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
## | **1** |StackedEnsemble_AllModels_AutoML_20210505_045455 | 0.0557395152563593 | 0.236092175339123 | 0.0557395152563593 | 0.113762482812469 | 0.165518002900473 | 1457 | 0.038592 |
## | **2** |StackedEnsemble_BestOfFamily_AutoML_20210505_045455 | 0.0574256788168178 | 0.239636555677171 | 0.0574256788168178 | 0.11941385984812 | 0.167170541363701 | 1927 | 0.010959 |
## | **3** |DRF_1_AutoML_20210505_045455 | 0.0710622073744927 | 0.266574956390304 | 0.0710622073744927 | 0.0833068390498957 | 0.185527884000982 | 319 | 0.003534 |
## | **4** |GBM_4_AutoML_20210505_045455 | 0.169159069686495 | 0.411289520516261 | 0.169159069686495 | 0.357063101727424 | 0.285610433018239 | 248 | 0.004279 |
## | **5** |GBM_1_AutoML_20210505_045455 | 0.170054819702023 | 0.412377035856779 | 0.170054819702023 | 0.357843284411548 | 0.286416212104768 | 260 | 0.005474 |
## | **6** |GBM_3_AutoML_20210505_045455 | 0.170257079290382 | 0.412622199221494 | 0.170257079290382 | 0.357981824235989 | 0.286584389756804 | 166 | 0.009214 |
## | **7** |GBM_5_AutoML_20210505_045455 | 0.171948440340909 | 0.414666661718674 | 0.171948440340909 | 0.359562662827614 | 0.288081781277177 | 176 | 0.002838 |
## | **8** |GBM_2_AutoML_20210505_045455 | 0.172277909993928 | 0.415063742085391 | 0.172277909993928 | 0.360285788625866 | 0.288506532120334 | 449 | 0.008779 |
## | **9** |GLM_1_AutoML_20210505_045455 | 0.181994326437689 | 0.426607930584616 | 0.181994326437689 | 0.37011547725331 | 0.297290838198071 | 491 | 0.006688 |
##
##
## Residual Analysis
## =================
##
## > Residual Analysis plots the fitted values vs residuals on a test dataset. Ideally, residuals should be randomly distributed. Patterns in this plot can indicate potential problems with the model selection, e.g., using simpler model than necessary, not accounting for heteroscedasticity, autocorrelation, etc. Note that if you see "striped" lines of residuals, that is an artifact of having an integer valued (vs a real valued) response variable.
##
##
## Variable Importance
## ===================
##
## > The variable importance plot shows the relative importance of the most important variables in the model.
##
##
## Variable Importance Heatmap
## ===========================
##
## > Variable importance heatmap shows variable importance across multiple models. Some models in H2O return variable importance for one-hot (binary indicator) encoded versions of categorical columns (e.g. Deep Learning, XGBoost). In order for the variable importance of categorical columns to be compared across all model types we compute a summarization of the the variable importance across all one-hot encoded features and return a single variable importance for the original categorical feature. By default, the models and variables are ordered by their similarity.
##
##
## Model Correlation
## =================
##
## > This plot shows the correlation between the predictions of the models. For classification, frequency of identical predictions is used. By default, models are ordered by their similarity (as computed by hierarchical clustering).
## Interpretable models: GLM_1_AutoML_20210505_045455
##
##
## SHAP Summary
## ============
##
## > SHAP summary plot shows the contribution of the features for each instance (row of data). The sum of the feature contributions and the bias term is equal to the raw prediction of the model, i.e., prediction before applying inverse link function.
##
##
## Partial Dependence Plots
## ========================
##
## > Partial dependence plot (PDP) gives a graphical depiction of the marginal effect of a variable on the response. The effect of a variable is measured in change in the mean response. PDP assumes independence between the feature for which is the PDP computed and the rest.
##
##
## Individual Conditional Expectations
## ===================================
##
## > An Individual Conditional Expectation (ICE) plot gives a graphical depiction of the marginal effect of a variable on the response. ICE plots are similar to partial dependence plots (PDP); PDP shows the average effect of a feature while ICE plot shows the effect for a single instance. This function will plot the effect for each decile. In contrast to the PDP, ICE plots can provide more insight, especially when there is stronger feature interaction.
1.The most sensible solution for your project is how much influence all predictor variables will have on
the response variable "Cool.Demand.Status", where the response variable contains (is 0 and 1).
2.Next we will find variables of importance, here are the variables solar_altitute_angle that are most decisive,
which is indicated by the Variable Important chart.
3. Furthermore, with a chart of each variable dependence, it can show in detail the contribution of
each variable predictor to the response variable.
#--------------Detail
# Explain a single H2O model (e.g. leader model from AutoML)
# exm <- h2o.explain(aml@leader, test)
# exm
# Explanation Plotting Functions
# Methods for an AutoML object
#h2o.varimp_heatmap()
#h2o.model_correlation_heatmap()
#h2o.pd_multi_plot()
# Methods for an H2O model
#h2o.residual_analysis_plot()
#h2o.varimp_plot()
#h2o.shap_explain_row_plot()
#h2o.shap_summary_plot()
#h2o.pd_plot()
#h2o.ice_plot()
# Parameters
# "leaderboard" (AutoML and list of models only)
# "residual_analysis" (regression only)
# "confusion_matrix" (classification only)
# "varimp" (not currently available for Stacked Ensembles)
# "varimp_heatmap"
# "model_correlation_heatmap"
# "shap_summary" (single models only)
# "pdp"
# "ice"