datarobot-oss/datarobot-agent-skills / skills/datarobot-predictions
datarobot-predictions
VerifiedTools and guidance for making predictions with DataRobot deployments, including real-time predictions, batch scoring, prediction dataset generation, and prediction explanations (SHAP/XEMP). Use when making predictions, running batch scoring, generating prediction datasets, or explaining individual predictions from a deployment.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 14.8 KB |
| scripts/generate_prediction_data_template.pyexecutable | script | 7.6 KB |
| scripts/get_deployment_features.pyexecutable | script | 4.2 KB |
| scripts/make_prediction.pyexecutable | script | 4.8 KB |
| scripts/validate_prediction_data.pyexecutable | script | 4.6 KB |
scripts/generate_prediction_data_template.py
View on GitHub#!/usr/bin/env python3
# Copyright (c) 2026 DataRobot, Inc. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""
Generate a CSV template for prediction data.
Usage:
python generate_prediction_data_template.py <deployment_id> [n_rows] [output_file]
Generates a CSV template with all required columns and sample values.
"""
import csv
import sys
from datetime import datetime
import datarobot as dr
def generate_prediction_data_template(
deployment_id: str, n_rows: int = 1, output_file: str | None = None
) -> str:
"""
Generate a CSV template for prediction data.
Args:
deployment_id: The deployment ID
n_rows: Number of template rows to generate (default: 1)
output_file: Optional output file path (default: prints to stdout)
Returns:
CSV template content
"""
# Initialize client
dr.Client()
# Get deployment features (list of plain dicts with keys name, feature_type,
# importance, date_format, known_in_advance)
deployment = dr.Deployment.get(deployment_id)
try:
features = deployment.get_features()
except dr.errors.ClientError as e:
sys.exit(f"Deployment feature metadata unavailable ({e})")
target_name = deployment.model.get(
"target_name"
) # None for unsupervised/anomaly deployments
# Filter out target feature
prediction_features = [f for f in features if f["name"] != target_name]
if not prediction_features:
sys.exit(
"No feature metadata available for this deployment (custom/unstructured "
"models do not publish a feature list); cannot generate a template."
)
# Look up real training values: categorical levels and numeric ranges. Only
# DataRobot-built models have a backing project; custom-model deployments — and
# deployments whose training project was since deleted — fall back to the type
# placeholders below.
project_id = deployment.model.get("project_id")
stats_note = ""
if project_id:
try:
dr.Project.get(project_id)
except dr.errors.ClientError:
project_id = None
stats_note = (
"# Note: training statistics unavailable (project not accessible); "
"values below are type placeholders\n"
)
categorical_levels: dict[str, list[str]] = {}
level_notes: dict[str, str] = {}
numeric_stats: dict[str, dict[str, float]] = {}
if project_id:
for feature in prediction_features:
try:
if feature["feature_type"] in ("Categorical", "Boolean"):
dr_feature = dr.Feature.get(project_id, feature["name"])
# Each bin is {"label": <level>, "count": ..., "target": ...};
# high-cardinality features get at most 60 bins by default.
labels = [b["label"] for b in dr_feature.get_histogram().plot]
# The histogram injects aggregate pseudo-buckets that are NOT
# real levels: "=All Other=" (levels beyond the bin cap) and
# "==Missing==" (the feature had NAs in training). Filter them
# out, but surface what they tell us in the header notes.
levels = [
label
for label in labels
if not (str(label).startswith("=") and str(label).endswith("="))
]
if levels:
categorical_levels[feature["name"]] = levels
notes = []
if "=All Other=" in labels and dr_feature.unique_count:
notes.append(
f"top {len(levels)} of {dr_feature.unique_count} levels"
)
if "==Missing==" in labels:
notes.append("missing allowed - leave blank")
if notes:
level_notes[feature["name"]] = "; ".join(notes)
elif feature["feature_type"] in ("Numeric", "Percentage"):
stats = dr.Feature.get(project_id, feature["name"])
if isinstance(stats.median, (int, float)):
numeric_stats[feature["name"]] = {
"min": stats.min,
"max": stats.max,
"median": stats.median,
}
except Exception: # noqa: BLE001, S110 - best-effort statistics, fall back to the placeholder
pass # keep the type placeholder for this feature
# Generate template rows with sample values
import io
output = io.StringIO()
writer = csv.DictWriter(output, fieldnames=[f["name"] for f in prediction_features])
writer.writeheader()
# Generate sample rows based on feature types
for i in range(n_rows):
row = {}
for feature in prediction_features:
ftype = feature["feature_type"]
if ftype in ("Numeric", "Percentage"):
stats = numeric_stats.get(feature["name"])
row[feature["name"]] = stats["median"] if stats else 0.0
elif ftype in ("Categorical", "Boolean"):
levels = categorical_levels.get(feature["name"])
if levels:
row[feature["name"]] = levels[i % len(levels)]
else:
row[feature["name"]] = (
"sample_category" if ftype == "Categorical" else "0"
)
elif ftype == "Text":
row[feature["name"]] = "sample text"
elif ftype == "Date":
# Render the sample in the format the deployment expects
fmt = feature.get("date_format") or "%Y-%m-%d"
row[feature["name"]] = datetime(2024, 1, 15, 12, 30, 45).strftime(fmt)
elif ftype in ("Image", "Document"):
row[feature["name"]] = "path/to/file"
else:
row[feature["name"]] = ""
writer.writerow(row)
csv_content = output.getvalue()
# Add metadata comments
level_comments = "".join(
f"# Valid values for {name}: {', '.join(levels)}"
+ (f" ({level_notes[name]})" if name in level_notes else "")
+ "\n"
for name, levels in categorical_levels.items()
) + "".join(
f"# Range for {name}: {s['min']} to {s['max']} (median {s['median']})\n"
for name, s in numeric_stats.items()
)
metadata_comments = f"""# Prediction Data Template for Deployment: {deployment_id}
# Model: {deployment.model.get("project_name", "unknown")}
# Target: {target_name}
# Generated: {n_rows} template rows
{stats_note}{level_comments}#
# Instructions:
# 1. Fill in the values for each feature
# 2. Ensure data types match feature types
# 3. Use validate_prediction_data.py to check before submitting
#
"""
full_content = metadata_comments + csv_content
if output_file:
with open(output_file, "w") as f:
f.write(full_content)
return f"Template written to {output_file}"
else:
return full_content
if __name__ == "__main__":
if len(sys.argv) < 2:
print(
"Usage: python generate_prediction_data_template.py <deployment_id> [n_rows] [output_file]",
file=sys.stderr,
)
sys.exit(1)
deployment_id = sys.argv[1]
n_rows = int(sys.argv[2]) if len(sys.argv) > 2 else 1
output_file = sys.argv[3] if len(sys.argv) > 3 else None
result = generate_prediction_data_template(deployment_id, n_rows, output_file)
print(result)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |