Skip to content

Commit

Permalink
Merge pull request #1 from vb100/experiment
Browse files Browse the repository at this point in the history
Create cml.yaml
  • Loading branch information
vb100 authored Feb 17, 2022
2 parents f2200ce + 64b26c5 commit 77b226d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/cml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: mlops-exaple-tensorflow-regression
on: [push]
jobs:
run:
runs-on: [ubuntu-latest]
container: docker://dvcorg/cml-py3:latest
steps:
- uses: actions/checkout@v2
- name: 'Train my model'
env:
repo_token: ${{ secrets.GITHUB_TOKEN }}
run: |
# Your ML workflow goes here
pip install -r requirements.txt
python model.py
echo "## Model Metrics" > report.md
cat metrics.txt >> report.md
echo "\n## Model Performance" >> report.md
echo "Model performance metrics are on the plot below." >> report.md
cml-publish model_results.png --md >> report.md
cml-send-comment report.md
12 changes: 6 additions & 6 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def plot_predictions(train_data, train_labels, test_data, test_labels, predict
"""
Plots training data, test data and compares predictions.
"""
plt.figure(figsize=(10, 7))
plt.figure(figsize=(6, 5))
# Plot training data in blue
plt.scatter(train_data, train_labels, c="b", label="Training data")
# Plot test data in green
Expand Down Expand Up @@ -75,7 +75,7 @@ def mse(y_test, y_pred):
# Create a model using the Sequential API
model = tf.keras.Sequential([
tf.keras.layers.Dense(1),
#tf.keras.layers.Dense(1)
tf.keras.layers.Dense(1)
])

# Compile the model
Expand All @@ -84,12 +84,12 @@ def mse(y_test, y_pred):
metrics = ['mae'])

# Fit the model
model.fit(X_train, y_train, epochs=50)
model.fit(X_train, y_train, epochs=100)


# Make and plot predictions for model_1
y_preds = model.predict(X_test)
#plot_predictions(train_data=X_train, train_labels=y_train, test_data=X_test, test_labels=y_test, predictions=y_preds)
plot_predictions(train_data=X_train, train_labels=y_train, test_data=X_test, test_labels=y_test, predictions=y_preds)


# Calculate model_1 metrics
Expand All @@ -98,5 +98,5 @@ def mse(y_test, y_pred):
print(f'\nMean Absolute Error = {mae_1}, Mean Squared Error = {mse_1}.')

# Write metrics to file
#with open('metrics.txt', 'w') as outfile:
# outfile.write(f'\nMean Absolute Error = {mae_1}, Mean Squared Error = {mse_1}.')
with open('metrics.txt', 'w') as outfile:
outfile.write(f'\nMean Absolute Error = {mae_1}, Mean Squared Error = {mse_1}.')

1 comment on commit 77b226d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model Metrics

Mean Absolute Error = 3.74, Mean Squared Error = 17.07.

Model Performance

Model performance metrics are on the plot below.

CML watermark

Please sign in to comment.