-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
102 lines (71 loc) · 2.73 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
title: "R/iprobit: Binary and multinomial probit regression using I-priors"
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE)
library(iprobit)
```
[![Build Status](https://travis-ci.org/haziqj/iprobit.svg?branch=master)](https://travis-ci.org/haziqj/iprobit)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/haziqj/iprobit?branch=master&svg=true)](https://ci.appveyor.com/project/haziqj/iprobit)
[![Coverage Status](https://img.shields.io/codecov/c/github/haziqj/iprobit/master.svg)](https://codecov.io/gh/haziqj/iprobit)
This is an `R` package which extends I-prior regression to unordered categorical responses via a probit link function. This allows the user to fit models for classification or inference using fitted probabilities. Estimation is performed using a variational EM algorithm. Visit [http://phd.haziqj.ml](http://phd.haziqj.ml) for details.
## Binary classification (toy example)
#### Model fitting
```{r}
dat <- gen_spiral(n = 300, seed = 123) # generate binary toy example data set
mod <- iprobit(y ~ X1 + X2, dat, one.lam = TRUE, kernel = "fbm")
```
#### Model summary
```{r}
summary(mod)
```
#### Boundary plot for two-dimensional covariates
```{r}
iplot_predict(mod)
```
## Multiclass classification (toy example)
#### Model fit report and parameter estimates
```{r}
dat <- gen_mixture(n = 400, m = 4, sd = 1.5, seed = 123) # generate 4-class
# toy example data set
(mod <- iprobit(y ~ X1 + X2, dat, train.samp = sample(1:400, size = 392),
control = list(maxit = 10))) # set aside 8 points for testing
```
#### Boundary plot for two-dimensional covariates
```{r}
iplot_predict(mod, dec.bound = TRUE, plot.test = TRUE, grid.len = 50)
```
#### Obtain out-of-sample test error rates, predicted classes and probabilities
```{r}
predict(mod)
```
## Fisher's Iris data set
#### Model fitting (common RKHS scale across classes for each covariate)
```{r, echo = -1}
set.seed(123)
mod <- iprobit(Species ~ ., iris, kernel = "fbm", one.lam = TRUE,
common.RKHS.scale = TRUE, common.intercept = FALSE,
control = list(alpha0 = 1, theta0 = 1,
stop.crit = 1e-1))
summary(mod)
```
#### Obtain training error rates, predicted classes and probabilities with posterior quantiles
```{r}
fitted(mod, quantiles = TRUE)
```
#### Monitor convergence
```{r}
iplot_lb(mod)
```
#### Plot of training error over time
```{r}
iplot_error(mod)
```
#### Plot of fitted probabilities
```{r}
iplot_fitted(mod)
```
***
Copyright (C) 2017 [Haziq Jamil](http://haziqj.ml).