---
title: "Explain Wine Example"
output:
  html_document:
    df_print: paged
---

```{r}
library(h2o)
h2o.init()
h2o.no_progress()
```

```{r}
df <- h2o.importFile("https://h2o-public-test-data.s3.amazonaws.com/smalldata/wine/winequality-redwhite-no-BOM.csv")

response <- "quality"

predictors <- c(
  "fixed acidity", "volatile acidity", "citric acid", "residual sugar", "chlorides", "free sulfur dioxide",
  "total sulfur dioxide", "density", "pH", "sulphates", "alcohol",  "type"
)


df_splits <- h2o.splitFrame(df, seed = 1)
train <- df_splits[[1]]
test <- df_splits[[2]]
```

```{r}
aml <- h2o.automl(predictors, response, train, max_runtime_secs = 120)
```
```{r fig.height=5, fig.width=10, results='asis'}
h2o.explain(aml, test)
```

```{r fig.height=5, fig.width=10, results='asis'}
h2o.explain_row(aml, test, row_index = 42)
```
