---
title: "Supported Packages and Additional Functions"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Supported Packages and Additional Functions}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```
## Introduction

This vignette lists the packages and model types exported by **pmml**, as well as data transformations and functions that extend the basic exporter functionality.

## Supported packages

This package supports the following packages and model types:

- Anomaly Detection
    - [isofor](https://github.com/gravesee/isofor): `iForest`
    - [e1071](https://CRAN.R-project.org/package=e1071): `svm` with "one-classification" type
- Clustering
    - [amap](https://CRAN.R-project.org/package=amap): `hclust`
    - [neighbr](https://CRAN.R-project.org/package=neighbr): `neighbr`
    - stats: `kmeans`
- K Nearest Neighbors
    - [neighbr](https://CRAN.R-project.org/package=neighbr): `neighbr`
- Linear Models
    - [glmnet](https://CRAN.R-project.org/package=glmnet): `cv.glmnet` with "gaussian" and "poisson" family types
    - [nnet](https://CRAN.R-project.org/package=nnet): `multinom`
    - stats: `glm`, `lm` without interaction terms
- Naive Bayes
    - [e1071](https://CRAN.R-project.org/package=e1071): `naiveBayes`
- Neural Networks
    - [nnet](https://CRAN.R-project.org/package=nnet): `nnet`
- Support Vector Machines
    - [e1071](https://CRAN.R-project.org/package=e1071): `svm`
    - [kernlab](https://CRAN.R-project.org/package=kernlab): `ksvm` with "rbfdot", "polydot", "vanilladot", and "tanhdot" kernels
- Time Series
    - [forecast](https://CRAN.R-project.org/package=forecast): `Arima`
- Tree-based Models and Ensembles
    - [ada](https://CRAN.R-project.org/package=ada): `ada`
    - [gbm](https://CRAN.R-project.org/package=gbm): `gbm` with "bernoulli", "poisson", and "multinomial" distribution types
    - [randomForest](https://CRAN.R-project.org/package=randomForest): `randomForest`
    - [rpart](https://CRAN.R-project.org/package=rpart): `rpart`
    - [xgboost](https://CRAN.R-project.org/package=xgboost): `xgb.Booster` with "multi:softprob", "multi:softmax", and "binary:logistic" objectives
- Other Packages
    - [arules](https://CRAN.R-project.org/package=arules): `rules` and `itemsets`
    - [survival](https://CRAN.R-project.org/package=survival): `coxph`


## Data transformations
The following functions are used to transform input data.

- `xform_discretize`: discretize continuous values.
- `xform_function`: apply a user-defined function to the input values.
- `xform_map`: map discrete values between input and output.
- `xform_min_max`: normalize continuous values.
- `xform_norm_discrete`: normalize discrete values.
- `xform_z_score`: apply z-score normalization to continuous values.

The general methodology is to first wrap the data with `xform_wrap`, and then perform transformations using the above functions.

## Additional functions
The following functions allow additional operations, such as creating specific nodes and adding attributes. For more information, check the documentation for each function.

- `add_attributes`: add attribute values to an existing element in a given PMML file.
- `add_data_field_attributes`: add attribute values to an existing DataField element in a given PMML file.
- `add_data_field_children`: add 'Interval' and 'Value' child elements to a given DataField element in a given PMML file.
- `add_mining_field_attributes`: add attribute values to an existing MiningField element in a given PMML file.
- `add_output_field`: add Output nodes to a PMML object.
- `file_to_xml_node`: read in a file and parse it into an object of type XMLNode.
- `function_to_pmml`: convert an R expression to PMML.
- `make_intervals`: create Interval elements to add to a DataDictionary element.
- `make_output_nodes`: add Output nodes to a PMML object.
- `make_values`: create Values element to add to a DataDictionary element.

## References
- [DMG PMML 4.4.1 specification](https://dmg.org/pmml/v4-4-1/GeneralStructure.html)