Skip to content

Commit

Permalink
add model metrics in model_card.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ympaik87 committed Jan 13, 2022
1 parent 86aa90a commit a33a8fe
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions starter/model/model_metrics.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
precision,recall,fbeta_score
0.8159117305458768,0.5614011720831114,0.665141234022408
9 changes: 8 additions & 1 deletion starter/model_card.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ For additional information see the Model Card paper: https://arxiv.org/pdf/1810.

## Metrics

* The model is evaluated by F1 score.
* The model is evaluated by precision, recall, and F1 scores.
* The scores are following:

| Metrics | Scores |
| ------- | ------ |
| Precision | 0.8159 |
| Recall | 0.5614 |
| F1 | 0.6651 |

## Ethical Considerations

Expand Down
28 changes: 28 additions & 0 deletions starter/starter/model_metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pandas as pd
from joblib import load
from ml import model, data
from train_model import CAT_FEATURES


def compute_score(datapath='../data/census_cleaned.csv'):
data_df = pd.read_csv(datapath)

model_trained = load("../model/model_trained.joblib")
encoder = load("../model/encoder.joblib")
label = load("../model/lb.joblib")

X_test, y_test, _, _ = data.process_data(
data_df,
categorical_features=CAT_FEATURES,
label="salary", encoder=encoder, lb=label, training=False)
y_preds = model_trained.predict(X_test)
prc, rcl, fb1 = model.compute_model_metrics(y_test, y_preds)

metrics_df = pd.DataFrame(
{"precision": prc, "recall": rcl, "fbeta_score": fb1}, index=[0])

metrics_df.to_csv('../model/model_metrics.txt', index=False)


if __name__ == '__main__':
compute_score()

0 comments on commit a33a8fe

Please sign in to comment.