# F1 Score

## Preliminaries

```
# Load libraries
from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import make_classification
```

## Generate Features And Target Data

```
# Generate features matrix and target vector
X, y = make_classification(n_samples = 10000,
n_features = 3,
n_informative = 3,
n_redundant = 0,
n_classes = 2,
random_state = 1)
```

## Create Logistic Regression

```
# Create logistic regression
logit = LogisticRegression()
```

## Cross-Validate Model Using F1

```
# Cross-validate model using precision
cross_val_score(logit, X, y, scoring="f1")
```

```
array([ 0.95166617, 0.95765275, 0.95558223])
```

#### Find an error or bug?

Everything on this site is available on GitHub. Head to and submit a change.