-
Notifications
You must be signed in to change notification settings - Fork 8
/
README.Rmd
112 lines (83 loc) · 3.93 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
103
104
105
106
107
108
109
110
111
112
---
output: github_document
---
```{r echo=FALSE, results = 'asis'}
pkg <- 'stream'
source("https://raw.githubusercontent.com/mhahsler/pkg_helpers/main/pkg_helpers.R")
pkg_title(pkg)
```
## Introduction
The package provides support for modeling and simulating data streams as well as an extensible framework for implementing, interfacing and
experimenting with algorithms for various data stream mining tasks. The main advantage of stream is that it seamlessly integrates with the large existing infrastructure provided by R. The package provides:
* **Stream Sources:** streaming from files, databases, in-memory data, URLs, pipes,
socket connections and several data stream generators including
dynamically streams with concept drift.
* **Stream Processing** with filters (convolution, scaling, exponential moving average, ...)
* **Stream Aggregation:** sampling, windowing.
* **Stream Clustering:** **BICO**, **BIRCH**, **D-Stream**, **DBSTREAM**, and **evoStream**.
* **Stream Outlier Detection** based on **D-Stream**, **DBSTREAM**.
* **Stream Classification** with **DecisionStumps**, **HoeffdingTree**, **NaiveBayes**
and **Ensembles** (streamMOA via RMOA).
* **Stream Regression** with **Perceptron**, **FIMTDD**, **ORTO**, ... (streamMOA via RMOA).
* **Stream Mining Evaluation** with prequential error estimation.
Additional packages in the stream family are:
* [streamConnect](https://github.com/mhahsler/streamConnect): Connect stream mining
components using sockets and web services.
* [streamMOA](https://github.com/mhahsler/streamMOA): Interface to clustering
algorithms implemented in the [MOA](https://moa.cms.waikato.ac.nz/) framework.
The package interfaces clustering algorithms like of **DenStream**, **ClusTree**,
**CluStream** and **MCOD**.
The package also provides an interface to [RMOA](https://github.com/jwijffels/RMOA) for
MOA's stream classifiers and stream regression models.
* [rEMM](https://github.com/mhahsler/rEMM): Provides implementations of
**threshold nearest neighbor clustering** (tNN) and
**Extensible Markov Model** (EMM) for modelling temporal relationships between clusters.
```{r echo=FALSE, results = 'asis'}
pkg_citation(pkg, 2)
pkg_install(pkg)
```
## Usage
```{r echo=FALSE}
options(digits = 3)
```
Load the package and a random data stream with 3 Gaussian clusters and 10\% noise and scale the data to z-scores.
```{r stream}
library("stream")
set.seed(2000)
stream <- DSD_Gaussians(k = 3, d = 2, noise= .1) %>% DSF_Scale()
get_points(stream, n = 5)
plot(stream)
```
Cluster a stream of 1000 points using D-Stream which estimates point density in grid cells.
```{r Dstream}
dsc <- DSC_DStream(gridsize = .1)
update(dsc, stream, 1000)
plot(dsc, stream, grid = TRUE)
```
```{r Dstream_eval}
evaluate_static(dsc, stream, n = 100)
```
Outlier detection using DBSTREAM which uses micro-clusters with a given radius.
```{r DSOutlier_DBSTREAM}
dso <- DSOutlier_DBSTREAM(r = .1)
update(dso, stream, 1000)
plot(dso, stream)
```
```{r DSO_eval}
evaluate_static(dso, stream, n = 100, measure = c("numPoints", "noiseActual", "noisePredicted", "noisePrecision"))
```
Preparing complete stream process pipelines that can be run using a single `update()` call.
```{r pipeline}
pipeline <- DSD_Gaussians(k = 3, d = 2, noise= .1) %>%
DSF_Scale() %>%
DST_Runner(DSC_DStream(gridsize = .1))
pipeline
update(pipeline, n = 500)
pipeline$dst
```
## Acknowledgments
The development of the stream package was supported in part by NSF IIS-0948893, NSF CMMI 1728612, and NIH R21HG005912.
## References
* Michael Hahsler, Matthew Bolaños, and John Forrest. [stream: An extensible framework for data stream clustering research with R.](https://dx.doi.org/10.18637/jss.v076.i14) _Journal of Statistical Software,_ 76(14), February 2017.
* [stream package vignette](https://cran.r-project.org/package=stream/vignettes/stream.pdf) with complete examples.
* [stream reference manual](https://cran.r-project.org/package=stream/stream.pdf)