-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
65 lines (46 loc) · 1.72 KB
/
README.Rmd
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
---
title: "README"
author: "Max Pichler"
output:
html_document:
keep_md: yes
---
![R-CMD-check](https://github.com/MaximilianPi/TraitMatching/workflows/R-CMD-check/badge.svg)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
# TraitMatching package
This is a new implementation of the TraitMatching (see https://github.com/TheoreticalEcology/Pichler-et-al-2019 ) package based on mlr3.
More about using machine learning for TraitMatching: https://doi.org/10.1111/2041-210X.13329
To install the package:
```r
devtools::install_github(repo = "https://github.com/MaximilianPi/TraitMatching", subdir = "TraitMatching")
library(TraitMatching)
```
### Workflow
1) simulate data (replace the A, B, and Z matrices with your own):
```{r}
library(TraitMatching)
sim = simulateInteraction(weights = list(main = 0.1, inter = c(0.3,0.3,0.3)))
A = sim$A
B = sim$B
Z = sim$binar()
community = createCommunity(A, B, Z)
```
2) Fit random forest in a nested resampling strategy and with hyper-parameter tuning:
```{r, message=FALSE,results='hide'}
result = runTM(community = community, method = "RF", iters = 20L)
```
```{r}
print(result)
```
3) Compare different ML algorithms:
```{r, message=FALSE,results='hide'}
result = runTM(community = community, method = c("RF", "SVM"), iters = 3L)
```
```{r}
print(result)
```
4) Predict target for new data with different ensemble ML algorithms (trained with optimal hyper-parameters)
```{r}
predict(result, newdata=community$data[1:5,])
```