nnet: Interfaces for nnet package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

Interfaces to nnet functions that can be used in a pipeline implemented by magrittr.

Usage

1
2

Arguments

data

data frame, tibble, list, ...

...

Other arguments passed to the corresponding interfaced function.

Details

Interfaces call their corresponding interfaced function.

Value

Object returned by interfaced function.

Author(s)

Roberto Bertolusso

Examples

 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
## Not run: 
library(intubate)
library(magrittr)
library(nnet)

## multinom
options(contrasts = c("contr.treatment", "contr.poly"))
library(MASS)
example(birthwt)

## Original function to interface
multinom(low ~ ., bwt)

## The interface reverses the order of data and formula
ntbt_multinom(bwt, low ~ .)

## so it can be used easily in a pipeline.
bwt %>%
  ntbt_multinom(low ~ .)

## nnet
ir <- rbind(iris3[,,1],iris3[,,2],iris3[,,3])
targets <- class.ind( c(rep("s", 50), rep("c", 50), rep("v", 50)))
set.seed(6789) ## for reproducible results
samp <- c(sample(1:50,25), sample(51:100,25), sample(101:150,25))
ird <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]),
                  species = factor(c(rep("s",50), rep("c", 50), rep("v", 50))))

## Original function to interface
set.seed(12345) ## for reproducible results
nnet(species ~ ., data = ird, subset = samp,
     size = 2, rang = 0.1, decay = 5e-4, maxit = 200)

## The interface reverses the order of data and formula
set.seed(12345) ## for reproducible results
ntbt_nnet(data = ird, species ~ ., subset = samp,
          size = 2, rang = 0.1, decay = 5e-4, maxit = 200)

## so it can be used easily in a pipeline.
set.seed(12345) ## for reproducible results
ird %>%
  ntbt_nnet(species ~ ., subset = samp,
            size = 2, rang = 0.1, decay = 5e-4, maxit = 200)

## End(Not run)

rbertolusso/intubate documentation built on May 27, 2019, 3 a.m.