Skip to content

Commit d8a6931

Browse files
committed
Add multi-hop sensor network dataset
1 parent 07ef17f commit d8a6931

File tree

24 files changed

+39664
-0
lines changed

24 files changed

+39664
-0
lines changed

lib/node_modules/@stdlib/datasets/suthaharan-multi-hop-sensor-network/LICENSE

Lines changed: 930 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2018 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# Multi-Hop Sensor Network
22+
23+
> Labeled wireless sensor network data set collected from a multi-hop wireless sensor network deployment using TelosB motes.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var dataset = require( '@stdlib/datasets/suthaharan-multi-hop-sensor-network' );
31+
```
32+
33+
#### dataset()
34+
35+
Returns a dataset consisting of labeled wireless sensor network data set collected from a multi-hop wireless sensor network deployment using TelosB motes.
36+
37+
```javascript
38+
var data = dataset();
39+
/* returns
40+
[
41+
{
42+
'reading': 1,
43+
'mote_id': 1,
44+
'indoor': 0,
45+
'humidity': 43.82,
46+
'temperature': 30.21,
47+
'label': 0
48+
},
49+
...
50+
]
51+
*/
52+
```
53+
54+
</section>
55+
56+
<!-- /.usage -->
57+
58+
<section class="notes">
59+
60+
## Notes
61+
62+
- Humidity and temperature measurements were collected at `5` second intervals over a six hour period on July 10, 2010.
63+
- Temperature is in degrees Celsius.
64+
- Humidity is temperature corrected relative humidity, ranging from 0-100%.
65+
- The label `0` denotes normal data, and the label `1` denotes an introduced event.
66+
- If a mote was an indoor sensor, the corresponding indicator is `1`. If a mote was an outdoor sensor, the indoor indicator is `0`.
67+
68+
</section>
69+
70+
<!-- /.notes -->
71+
72+
<section class="examples">
73+
74+
## Examples
75+
76+
<!-- eslint no-undef: "error" -->
77+
78+
```javascript
79+
var incrgrubbs = require( '@stdlib/stats/incr/grubbs' );
80+
var data = require( '@stdlib/datasets/suthaharan-multi-hop-sensor-network' );
81+
82+
var acc;
83+
var d;
84+
var i;
85+
var j;
86+
var k;
87+
88+
// Get the sensor data:
89+
d = data();
90+
91+
// For each mote, test for an outlier temperature measurement...
92+
i = 0;
93+
for ( j = 0; j < 4; j++ ) {
94+
k = j + 1;
95+
96+
// Create a new accumulator for performing Grubbs' test:
97+
acc = incrgrubbs();
98+
99+
// Update the accumulator with temperature data...
100+
while ( i < d.length && d[ i ].mote_id === k ) {
101+
acc( d[ i ].temperature );
102+
i += 1;
103+
}
104+
// Print test results:
105+
console.log( '' );
106+
console.log( 'Mote: %d', k );
107+
console.log( '' );
108+
console.log( acc().print() );
109+
}
110+
```
111+
112+
</section>
113+
114+
<!-- /.examples -->
115+
116+
* * *
117+
118+
<section class="cli">
119+
120+
## CLI
121+
122+
<section class="usage">
123+
124+
### Usage
125+
126+
```text
127+
Usage: suthaharan-multi-hop-sensor-network [options]
128+
129+
Options:
130+
131+
-h, --help Print this message.
132+
-V, --version Print the package version.
133+
--format fmt Output format: 'csv' or 'ndjson'.
134+
```
135+
136+
</section>
137+
138+
<!-- /.usage -->
139+
140+
<section class="examples">
141+
142+
### Examples
143+
144+
```bash
145+
$ suthaharan-multi-hop-sensor-network
146+
```
147+
148+
</section>
149+
150+
<!-- /.examples -->
151+
152+
</section>
153+
154+
<!-- /.cli -->
155+
156+
* * *
157+
158+
<section class="references">
159+
160+
## References
161+
162+
- Suthaharan, Shan, Mohammed Alzahrani, Sutharshan Rajasegarar, Christopher Leckie, and Marimuthu Palaniswami. 2010. "Labelled data collection for anomaly detection in wireless sensor networks." In _Proceedings of the Sixth International Conference on Intelligent Sensors, Sensor Networks and Information Processing (ISSNIP 2010)_. Brisbane, Australia: IEEE.
163+
164+
</section>
165+
166+
<!-- /.references -->
167+
168+
<!-- <license> -->
169+
170+
## License
171+
172+
The data files (databases) are licensed under an [Open Data Commons Attribution 1.0 License][odc-by-1.0] and their contents are licensed under a [Creative Commons Attribution 4.0 International Public License][cc-by-4.0]. The original dataset is attributed to Shan Suthaharan, Mohammed Alzahrani, Sutharshan Rajasegarar, Christopher Leckie, and Marimuthu Palaniswami and can be found [here][suthaharan-multi-hop-sensor-network-data]. The software is licensed under [Apache License, Version 2.0][apache-license].
173+
174+
<!-- </license> -->
175+
176+
<section class="links">
177+
178+
[suthaharan-multi-hop-sensor-network-data]: http://www.uncg.edu/cmp/downloads/lwsndr.html
179+
180+
[odc-by-1.0]: http://opendatacommons.org/licenses/by/1.0/
181+
182+
[cc-by-4.0]: http://creativecommons.org/licenses/by/4.0/
183+
184+
[apache-license]: https://www.apache.org/licenses/LICENSE-2.0
185+
186+
</section>
187+
188+
<!-- /.links -->
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isObjectArray = require( '@stdlib/assert/is-plain-object-array' );
25+
var pkg = require( './../package.json' ).name;
26+
var data = require( './../lib/browser.js' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg+'::browser', function benchmark( b ) {
32+
var d;
33+
var i;
34+
35+
b.tic();
36+
for ( i = 0; i < b.iterations; i++ ) {
37+
d = data();
38+
if ( d.length === 0 ) {
39+
b.fail( 'should have a length greater than 0' );
40+
}
41+
}
42+
b.toc();
43+
if ( !isObjectArray( d ) ) {
44+
b.fail( 'should return an object array' );
45+
}
46+
b.pass( 'benchmark finished' );
47+
b.end();
48+
});
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var IS_BROWSER = require( '@stdlib/assert/is-browser' );
25+
var isObjectArray = require( '@stdlib/assert/is-plain-object-array' );
26+
var pkg = require( './../package.json' ).name;
27+
var data = require( './../lib' );
28+
29+
30+
// VARIABLES //
31+
32+
var opts = {
33+
'skip': IS_BROWSER
34+
};
35+
36+
37+
// MAIN //
38+
39+
bench( pkg, opts, function benchmark( b ) {
40+
var d;
41+
var i;
42+
43+
b.tic();
44+
for ( i = 0; i < b.iterations; i++ ) {
45+
d = data();
46+
if ( d.length === 0 ) {
47+
b.fail( 'should have a length greater than 0' );
48+
}
49+
}
50+
b.toc();
51+
if ( !isObjectArray( d ) ) {
52+
b.fail( 'should return an object array' );
53+
}
54+
b.pass( 'benchmark finished' );
55+
b.end();
56+
});
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* @license Apache-2.0
5+
*
6+
* Copyright (c) 2018 The Stdlib Authors.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var fs = require( 'fs' );
26+
var resolve = require( 'path' ).resolve;
27+
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
28+
var stdout = require( '@stdlib/streams/base/stdout' );
29+
var CLI = require( '@stdlib/tools/cli' );
30+
31+
32+
// MAIN //
33+
34+
/**
35+
* Main execution sequence.
36+
*
37+
* @private
38+
*/
39+
function main() {
40+
var flags;
41+
var cli;
42+
43+
// Create a command-line interface:
44+
cli = new CLI({
45+
'pkg': require( './../package.json' ),
46+
'options': require( './../etc/cli_opts.json' ),
47+
'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
48+
'encoding': 'utf8'
49+
})
50+
});
51+
flags = cli.flags();
52+
if ( flags.format === 'ndjson' ) {
53+
ndjson();
54+
} else {
55+
csv();
56+
}
57+
58+
/**
59+
* Prints data as newline-delimited JSON (ndjson).
60+
*
61+
* @private
62+
*/
63+
function ndjson() {
64+
var data;
65+
var i;
66+
67+
data = require( './../data/data.json' );
68+
for ( i = 0; i < data.length; i++ ) {
69+
console.log( JSON.stringify( data[i] ) ); // eslint-disable-line no-console
70+
}
71+
}
72+
73+
/**
74+
* Prints data as lines of comma-separated values (CSV).
75+
*
76+
* @private
77+
*/
78+
function csv() {
79+
var fpath = resolve( __dirname, '..', 'data', 'data.csv' );
80+
fs.createReadStream( fpath )
81+
.pipe( stdout )
82+
.on( 'close', onClose );
83+
}
84+
85+
/**
86+
* Exits the CLI.
87+
*
88+
* @private
89+
*/
90+
function onClose() {
91+
cli.exit( 0 );
92+
}
93+
}
94+
95+
main();

0 commit comments

Comments
 (0)