Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

push chnages in main to test #2

Merged
merged 12 commits into from
Mar 16, 2024
46 changes: 46 additions & 0 deletions .github/workflows/update_readme.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Update README

on:
push:
branches:
- main

jobs:
update-readme:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mlflow tabulate

- name: Run script
run: python results/gen_result.py

- name: Commit results if it changed
run: |
git diff --exit-code --quiet results/best_runs.md || (git add results/best_runs.md && git commit -m "Update best runs")

- name: Replace results in README
run: |
results=$(cat results/best_runs.md) # Read the results

# Replace the results in the README
awk -v r="$results" '/<!--START-->/ {print; print r; f=1} /<!--END-->/ {f=0} !f' README.md > temp && mv temp README.md

- name: Commit and push if it changed
run: |
git diff
git config --global user.email "[email protected]"
git config --global user.name "Md Mijanur Rahman"
git commit -am "Update README with test results" || exit 0
git push
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ We use the classification models available in [tsai library](https://timeseriesa
## Results
You can find the results in the following table:

<iframe src="results/best_runs.md" width="100%" height="500px"></iframe>
<!--START-->
| Dataset | GRU_FCN | LSTM | LSTM_FCN |
|:----------------------|----------:|-----------:|-----------:|
| ECG200 | 0.91 | nan | 0.92 |
| HandMovementDirection | nan | nan | 0.486486 |
| Handwriting | nan | nan | 0.0752941 |
| ItalyPowerDemand | nan | 0.559767 | 0.910593 |
<!--END-->


## Authors
Expand Down
27 changes: 27 additions & 0 deletions results/gen_result.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
We will generate a table here with the results of the experiments from mlruns
"""

import mlflow
import git

basePath = git.Repo('.', search_parent_directories=True).working_tree_dir
mlflow.set_tracking_uri(f"file:{basePath}/mlruns")

def get_best_runs():

all_runs = mlflow.search_runs(search_all_experiments=True)
columns = ['tags.mlflow.runName', 'params.model_name', 'metrics.accuracy']
all_runs = all_runs[columns]
best_runs = all_runs.groupby(['tags.mlflow.runName', 'params.model_name']).agg({'metrics.accuracy': 'max'}).reset_index()
best_runs = best_runs.pivot(index='tags.mlflow.runName', columns='params.model_name', values='metrics.accuracy').reset_index()
best_runs.columns.name = None
best_runs = best_runs.rename(columns={'tags.mlflow.runName': 'Dataset'})
# save as markdown file
with open('best_runs.md', 'w') as f:
f.write(best_runs.to_markdown(index=False))


if __name__ == "__main__":
get_best_runs()

Loading