agentleFS
Google CloudKnown publisherGoogleCloudPlatform/cloud-solutions/projects/legacy-detox-demo/skills/model-evaluation/SKILL.md

model-evaluation

Skill135 starsChanged 6 months agoApache-2.0View on GitHub

This skill establishes a standardized framework for evaluating and visualizing machine learning models. It covers simple metrics (like accuracy) for balanced datasets, and advanced metrics (like AUC-PR and Confusion Matrices) for complex or imbalanced datasets (e.g., fraud detection, rare event prediction). - Libraries: matplotlib, seaborn, pandas, numpy, scikit-learn (for local visualization). - Engines: PySpark MLlib or BigQuery ML. When writing evaluation code: 1. Match Complexity: - For simple, balanced classification: Use Accuracy (standard). - For imbalanced classification (e.g., predicting a…

6 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When writing evaluation code:

    line 24
  2. Very specific:

    Local Visualization: If plotting is required, copy a small sample of predictions to local memory using .toPandas() (Spark) or .to_pandas() …

    line 31

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Skill: Model Evaluation, Visualisation & Interpretation

<!-- Disabling markdownlint MD029 to provide explicit ordering to avoid confusing the LLM. --><!-- markdownlint-disable MD029 -->

1. Description & Rationale

This skill establishes a standardized framework for evaluating and visualizing machine learning models. It covers simple metrics (like accuracy) for balanced datasets, and advanced metrics (like AUC-PR and Confusion Matrices) for complex or imbalanced datasets (e.g., fraud detection, rare event prediction).

2. Environment Prerequisites

  • Libraries: matplotlib, seaborn, pandas, numpy, scikit-learn (for local visualization).
  • Engines: PySpark MLlib or BigQuery ML.

3. Agent Execution Guidelines (System Prompts)

When writing evaluation code:

  1. Match Complexity:
    • For simple, balanced classification: Use Accuracy (standard).
    • For imbalanced classification (e.g., predicting a rare action): Enforce Area Under the Precision-Recall Curve (AUC-PR) and Confusion Matrix.
  2. Local Visualization: If plotting is required, copy a small sample of predictions to local memory using .toPandas() (Spark) or .to_pandas() (BigFrames) only for the visualization step.

4. Opinionated Code Patterns

A. Simple Evaluation (Accuracy)

Spark MLlib

from pyspark.ml.evaluation import MulticlassClassificationEvaluator

# Evaluate accuracy
predictions = pipeline_model.transform(test)
evaluator = MulticlassClassificationEvaluator(metricName="accuracy")
accuracy = evaluator.evaluate(predictions)
print(f"Model Accuracy: {accuracy:.2%}")

BigFrames ML

# Score the model (returns a DataFrame with metrics, including accuracy)
metrics = model.score(X_test, y_test)
print("Evaluation Metrics:")
print(metrics)

B. Advanced Evaluation (AUC-PR & Confusion Matrix for Imbalanced Data)

Spark MLlib AUC-PR

from pyspark.ml.evaluation import BinaryClassificationEvaluator

# Initialize evaluator for AUC-PR
evaluator = BinaryClassificationEvaluator(
    labelCol="label",
    rawPredictionCol="probability",
    metricName="areaUnderPR"
)
auc_pr = evaluator.evaluate(predictions)
print(f"AUC-PR: {auc_pr:.4f}")

Local Confusion Matrix Visualization (Spark or BigFrames)

import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics import confusion_matrix
import pandas as pd

# Convert a small sample of predictions to Pandas for plotting
# (Ensure 'predictions' is the evaluated DataFrame)
y_true = predictions.select("label").toPandas()
y_pred = predictions.select("prediction").toPandas()

cm = confusion_matrix(y_true, y_pred)
cm_df = pd.DataFrame(cm, index=['Actual Negative', 'Actual Positive'],
                         columns=['Predicted Negative', 'Predicted Positive'])

plt.figure(figsize=(6, 5))
sns.heatmap(cm_df, annot=True, fmt='d', cmap='Blues', cbar=False)
plt.title('Confusion Matrix')
plt.ylabel('Actual')
plt.xlabel('Predicted')
plt.show()

5. Verification Checklist

  • Metric Selection: Verify if the dataset is imbalanced. If yes, ensure AUC-PR is used instead of just accuracy.
  • Safe Local Conversion: Confirm that .toPandas() is only called on the final prediction summary/evaluation set, never on the main training dataset.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.