diff --git a/.github/workflows/cml.yaml b/.github/workflows/cml.yaml new file mode 100644 index 000000000..f31901701 --- /dev/null +++ b/.github/workflows/cml.yaml @@ -0,0 +1,19 @@ +name: CML +on: [push] +jobs: + train-and-report: + runs-on: ubuntu-latest + container: docker://ghcr.io/iterative/cml:0-dvc2-base1 + steps: + - uses: actions/checkout@v3 + - name: Train model + env: + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + pip install -r requirements.txt + python train.py # generate plot.png + + # # Create CML report + cat metrics.txt >> report.md + echo '![](./plot.png "Confusion Matrix")' >> report.md + cml comment create report.md \ No newline at end of file diff --git a/metrics.txt b/metrics.txt new file mode 100644 index 000000000..7ebc778b0 --- /dev/null +++ b/metrics.txt @@ -0,0 +1 @@ +Accuracy: 0.86 diff --git a/plot.png b/plot.png new file mode 100644 index 000000000..eddac2f02 Binary files /dev/null and b/plot.png differ diff --git a/train.py b/train.py index 415d9a9f9..64ce3873a 100644 --- a/train.py +++ b/train.py @@ -12,12 +12,12 @@ y_test = np.genfromtxt("data/test_labels.csv") # Fit a model -depth = 2 +depth = 5 clf = RandomForestClassifier(max_depth=depth) clf.fit(X_train, y_train) acc = clf.score(X_test, y_test) -print(acc) +print(f"acc:{acc}") with open("metrics.txt", "w") as outfile: outfile.write("Accuracy: " + str(acc) + "\n")