Skip to content

Commit

Permalink
Update readme example
Browse files Browse the repository at this point in the history
Co-authored-by: gvieralopez <[email protected]>
  • Loading branch information
jmorgadov and gvieralopez committed Aug 28, 2023
1 parent c369d0f commit e4ea76b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ This is quick example of how to test a Random Forest classifier on the Animals d
from pactus import Dataset, featurizers
from pactus.models import RandomForestModel

SEED = 0

# Load dataset
dataset = Dataset.animals()

# Split data into train and test subsets
train, test = dataset.split(0.9)
train, test = dataset.split(0.9, random_state=SEED)

# Convert trajectories into feature vectors
ft = featurizers.UniversalFeaturizer()

# Build and train the model
model = RandomForestModel(featurizer=ft)
model = RandomForestModel(featurizer=ft, random_state=SEED)
model.train(train, cross_validation=5)

# Evaluate the results on the test subset
Expand All @@ -58,22 +60,27 @@ It should output evaluation results similar to:
```text
General statistics:
Accuracy: 0.962
F1-score: 0.951
Mean precision: 0.976
Mean recall: 0.933
Accuracy: 0.885
F1-score: 0.849
Mean precision: 0.865
Mean recall: 0.850
Confusion matrix:
Cattle Deer Elk precision
================================
100.0 0.0 0.0 100.0
0.0 80.0 0.0 100.0
0.0 20.0 100.0 92.86
75.0 0.0 0.0 100.0
25.0 80.0 0.0 66.67
0.0 20.0 100.0 92.86
--------------------------------
100.0 80.0 100.0
75.0 80.0 100.0
```

> ℹ️ Notice that by setting the random state to a fixed seed, we ensure the
reproducibility of the results. By changing the seed value, results may be
slightly different due to the stochastic processes used when splitting the
dataset and training the model.

## Available datasets

See the whole [list of datasets](https://github.com/yupidevs/trajectory-datasets) compatible with pactus
Expand Down

0 comments on commit e4ea76b

Please sign in to comment.