-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from transferwise/time_tweaks
Small improvements to time series clustering functionality
- Loading branch information
Showing
12 changed files
with
386 additions
and
232 deletions.
There are no files selected for viewing
286 changes: 134 additions & 152 deletions
286
notebooks/Finding interesting segments in time series.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -9,5 +9,5 @@ scipy>=1.8.0 | |
tqdm | ||
cloudpickle | ||
pivottablejs | ||
streamlit==1.32.0 | ||
streamlit>=1.32.0 | ||
nbformat>=4.2.0 |
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
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,47 @@ | ||
import os, sys | ||
import pandas as pd | ||
|
||
root_path = os.path.realpath("../..") | ||
print(root_path) | ||
|
||
# this assumes that all of the following files are checked in the same directory | ||
sys.path.append(os.path.join(root_path, "wise-pizza")) | ||
|
||
# create data-related directories | ||
data_dir = os.path.realpath(os.path.join(root_path, "wise-pizza/data")) | ||
if not os.path.isdir(data_dir): | ||
os.mkdir(data_dir) | ||
print(data_dir) | ||
|
||
from wise_pizza import explain_timeseries | ||
|
||
df = pd.read_csv( | ||
os.path.join(data_dir, "volume_data_new.csv") | ||
) # replace this variable with your data | ||
dims = [ | ||
"CUSTOMER_TYPE", | ||
"STRATEGIC_PRODUCT", | ||
"SOURCE_CURRENCY", | ||
"TARGET_CURRENCY", | ||
"PRODUCT_USE_CASE", | ||
"REGION", | ||
"TRANS_VOL_BUCKET", | ||
] # dimensions to find segments | ||
totals = "VOLUME_GBP" # value to analyze | ||
size = "NUM_CUSTOMERS" #'NUM_TRANSACTIONS' # number of objects | ||
time = "ACTION_YM" | ||
sf = explain_timeseries( | ||
df=df, | ||
dims=dims, | ||
max_segments=7, | ||
max_depth=2, | ||
total_name=totals, | ||
size_name=size, | ||
time_name=time, | ||
verbose=False, | ||
solver="tree", | ||
fit_sizes=True, | ||
) | ||
sf.plot(plot_is_static=False, height=1500, width=1000, average_name="VPC") | ||
print(sf.summary()) | ||
print("yay!") |
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
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
Oops, something went wrong.