> For the complete documentation index, see [llms.txt](https://brianbuccaneer.gitbook.io/bottlenose/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brianbuccaneer.gitbook.io/bottlenose/v0.7.0/data-analysis/rxstats/operators/f1.md).

# f1

## Description

Given an `Observable` of ground-truth labels and predictions, the f1 operator returns the [f1 score](https://en.wikipedia.org/wiki/F1_score).

## Examples

```javascript
import { from } from 'rxjs';
import { skip } from 'rxjs/operators';
import { f1 } from '@bottlenose/rxstats';

const items = [
  [0, 1], // [trueLabel, predictedLabel]
  [1, 0],
  [1, 0],
  [0, 0],
  [0, 0],
  [1, 1],
  [1, 1],
  [1, 1],
  [1, 1],
  [1, 1],
];

const f1$ = from(items).pipe(
  f1(),
  skip(4)
);

f1$.subscribe(console.log);
// Output
// 0.4
// 0.571429
// 0.666667
// 0.727273
// 0.769231
```

## API

```
f1([initialState={truePositives: 0, falsePositives: 0, falseNegatives: 0}])
```

### Since

0.1

### Parameters

None

### Options

* `initialState: Object {truePositives: Number, falsePositives: Number, falseNegatives: 0}`: Sets a [warm start](https://app.gitbook.com/@brianbuccaneer/s/rxjs-stats/guides/warmstarts) value so that the calculation can continue from a non-zero starting point (instead of a blank state). The initialState should have these keys:
  * `truePositives: Number` is a count of the true positives
  * `falsePositives: Number` is a count of the false positives
  * `falseNegatives: Number` is a count of the false negatives

### Returns

`Number`. (The current f1 score of the `Observable`.)
