Skip to content

Instantly share code, notes, and snippets.

View renanxcortes's full-sized avatar

Renan Xavier Cortes renanxcortes

View GitHub Profile
# SHAP values: http://docs.h2o.ai/h2o/latest-stable/h2o-r/docs/reference/predict_contributions.H2OModel.html
SHAP_values <- predict_contributions.H2OModel(aml_leader, df_frame_split[[2]])
# Wrangling inspired here: https://bradleyboehmke.github.io/HOML/iml.html
shap_df <- SHAP_values %>%
as.data.frame() %>%
select(-BiasTerm) %>%
gather(feature, shap_value) %>%
@renanxcortes
renanxcortes / gist:c7127a23798122896a446098f1803e27
Created June 20, 2020 02:52
automl_with_shapley_snippet1_blogpost
# Metric for binary classification (deviance is the default). Check documentation here http://docs.h2o.ai/h2o/latest-stable/h2o-docs/automl.html
automl_model <- h2o.automl(#x = x,
y = 'y',
balance_classes = TRUE,
training_frame = df_frame_split[[1]],
nfolds = 4,
#validation_frame = df_frame_split[[2]], # read help(h2o.automl) !!!Optional. This argument is ignored unless the user sets nfolds = 0!!!
leaderboard_frame = df_frame_split[[2]],
max_runtime_secs = 60 * 2, # Two minutes
#exclude_algos = "StackedEnsemble", # Global Importance of Stacked models is tricky
@renanxcortes
renanxcortes / maxp-BasicTabu-bugs.ipynb
Created August 7, 2019 18:31
maxp-BasicTabu-bugs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@renanxcortes
renanxcortes / count_pixels_green_vectorized.ipynb
Created June 5, 2019 22:35
Zonal Statistics for Raster and Polygons L. Green
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.