forked from bluesheeptoken/CPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
54993ec
commit 555e402
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Benchmark | ||
|
||
## Data | ||
The benchmark has been realized on the [`FIFA`](https://www.philippe-fournier-viger.com/spmf/index.php?link=datasets.php) dataset. | ||
|
||
The training has been made with 20_450 sequences with an average length of 34 and an alphabet of 2990 elements. | ||
|
||
## Setup | ||
The benchmark has been realized with a PC with 8 GB of ram, 8 cores and the `Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz` CPU. | ||
|
||
## How to run the code | ||
You can get the data with `curl`: `curl http://www.philippe-fournier-viger.com/spmf/datasets/FIFA.txt --output FIFA.dat`. | ||
|
||
With `FIFA.dat` in the data folder, you can run the becnhmark from the root folder: `python benchmark/benchmark.py`. | ||
|
||
## Results | ||
Using multithreading, `CPT` made 4869 predictions per second, which is an average of 0.2 ms per prediction. | ||
|
||
However, most use case does not take advantage of multithreading. Without multithreading, `CPT` made 1662 predictions per second, which is an average of 0.6ms per prediction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import sys | ||
import time | ||
# Add cpt to python path | ||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | ||
|
||
from cpt import Cpt # pylint: disable=wrong-import-position | ||
|
||
with open("data/FIFA.dat") as file: | ||
data = list(map(lambda l: [int(x) for x in l.rstrip().split() if int(x) >= 0], file.readlines())) | ||
|
||
cpt = Cpt() | ||
|
||
cpt.fit(data) | ||
|
||
prediction_data = list(map(lambda x: x[-10:], data)) | ||
|
||
cpt.MBR = 10 | ||
cpt.noise_ratio = 0.2 | ||
|
||
time1 = time.time() | ||
cpt.predict(prediction_data, True) | ||
time2 = time.time() | ||
print(f"time ellapsed {(time2-time1)*1000} ms") |