featuresmith
  • Docs
  • SDK
  • CLI
  • Examples
  • Roadmap
v0.1.0
HomeExamples

Examples

Production-grade implementations demonstrating Featuresmith SDK pipelines, automated CI/CD quality gates, and custom rule design.

Python SDK Pipeline

This script illustrates loading a CSV dataset, executing deterministic audits targeting a leakage column, handling rule findings, and writing serialized reports to disk.

pipeline.py
python
1import json
2import featuresmith as fs
3
4def run_featuresmith_pipeline(data_path: str, target: str):
5 # 1. Load data safely into Dataset layer
6 print(f"Loading data from {data_path}...")
7 dataset = fs.load(data_path)
8
9 # 2. Run data audit checks (load → profile → rules evaluation)
10 print("Running rule audit...")
11 result = fs.analyze(
12 dataset,
13 target_column=target,
14 rule_config={
15 "quality.missing_value_threshold": {"threshold": 10.0},
16 "statistical.high_correlation": {"threshold": 0.85}
17 }
18 )
19
20 # 3. Handle rules results
21 print(f"Audit completed. Findings: {len(result.findings)}")
22 for finding in result.findings:
23 print(f"[{finding.severity.upper()}] Column: {finding.column_name}")
24 print(f" Issue : {finding.title}")
25 print(f" Detail : {finding.description}")
26
27 # 4. Serialize result to dictionary/JSON
28 report_dict = result.to_dict()
29 with open("report.json", "w") as f:
30 json.dump(report_dict, f, indent=2, default=str)
31
32if __name__ == "__main__":
33 run_featuresmith_pipeline("customers.csv", target="churn")

CI/CD Quality Gate

Integrate the Featuresmith CLI into your GitHub Actions workflow. Exit code 1 gates the build on critical quality or leakage violations, and uploads the generated text reports.

data-quality-gate.yml
yaml
1# .github/workflows/data-quality-gate.yml
2name: Data Quality Gate
3
4on:
5 push:
6 branches: [ main ]
7 schedule:
8 - cron: '0 0 * * *' # Run daily audits
9
10jobs:
11 audit:
12 runs-on: ubuntu-latest
13 steps:
14 - name: Checkout code
15 uses: actions/checkout@v4
16
17 - name: Set up Python
18 uses: actions/setup-python@v5
19 with:
20 python-version: '3.11'
21
22 - name: Install dependencies
23 run: |
24 pip install featuresmith-core featuresmith-cli
25
26 - name: Audit dataset quality
27 run: |
28 # Gate CI build: if critical rule violations exist, exit code 1 fails step
29 featuresmith analyze data/incoming_leads.csv --target converted --severity critical --output audit_report.txt
30
31 - name: Upload audit report
32 if: always()
33 uses: actions/upload-artifact@v4
34 with:
35 name: data-audit-report
36 path: audit_report.txt

Designing Custom Rules

Extend the BaseRule abstraction to create your own deterministic validation checks. This example detects numeric columns with zero standard deviation.

zero_variance.py
python
1from featuresmith.core.profile_result import ProfileResult
2from featuresmith.rules.base import BaseRule
3from featuresmith.core.rule_finding import RuleFinding
4
5class ZeroVarianceRule(BaseRule):
6 """Detect numeric columns with zero standard deviation."""
7
8 @property
9 def id(self) -> str:
10 return "statistical.zero_variance"
11
12 @property
13 def name(self) -> str:
14 return "Zero Variance Columns"
15
16 @property
17 def description(self) -> str:
18 return "Flags numeric columns with no observed variance."
19
20 @property
21 def category(self) -> str:
22 return "statistical"
23
24 @property
25 def severity(self) -> str:
26 return "warning"
27
28 @property
29 def enabled_by_default(self) -> bool:
30 return True
31
32 def evaluate(self, profile: ProfileResult) -> list[RuleFinding]:
33 findings: list[RuleFinding] = []
34 for col_name, numeric_profile in profile.numeric_profiles.items():
35 if numeric_profile.std_dev == 0.0:
36 findings.append(
37 RuleFinding(
38 rule_id=self.id,
39 rule_name=self.name,
40 category=self.category,
41 severity=self.severity,
42 column_name=col_name,
43 title="Zero Variance Detected",
44 description=f"Column '{col_name}' has standard deviation of 0.0 (no variance).",
45 evidence={"std_dev": numeric_profile.std_dev}
46 )
47 )
48 return findings

Included Example Datasets

Run the downloader utility in the root workspace to fetch and prepare these datasets programmatically:

python examples/download_datasets.py && python examples/prepare_datasets.py

Iris

Source: scikit-learn (load_iris)

Canonical clean machine learning dataset containing no missing values or outliers. Serves as a perfect baseline.

Rows: 150
Cols: 5
Audit: 0 findings

Titanic

Source: OpenML (titanic)

Messy historical log containing missing ages and duplicate tickets. Triggers missing value threshold rules.

Rows: 1,309
Cols: 14
Target: survived
Audit: Warnings (Missingness, Duplicates)

California Housing

Source: scikit-learn (fetch_california_housing)

Continuous spatial housing metrics with extreme values. Triggers numeric outlier detection and correlation rules.

Rows: 20,640
Cols: 9
Target: median_house_value
Audit: Warnings (Outliers, Correlation)

Customer Churn

Source: OpenML (Telco-Customer-Churn)

IBM subscriber records containing synthetic correlation columns. Triggers critical target leakage validations.

Rows: 7,043
Cols: 24
Target: churn_label
Audit: Critical (Target Leakage)

Retail Sales

Source: Synthetic Simulation (Superstore)

Transactional orders with datetime strings and empty fields. Triggers constant and fully empty column rules.

Rows: 1,000
Cols: 10
Audit: Critical (Empty), Warnings (Constant)

Jupyter Tutorial Notebooks

Step-by-step interactive notebooks located in examples/notebooks/:

Getting Started

Learn how to install Featuresmith, load datasets from CSV or DataFrame, run profiling, and view audit summaries.

01_getting_started.ipynb
View Source

Exploring Datasets & Statistical Profiling

Deep dive into continuous numeric summaries, categorical value distributions, datetime spans, and Pearson correlation matrices.

02_exploring_datasets.ipynb
View Source

Rule Engine Configs & Gating

Inspect validation findings, customize rule parameters (e.g. missingness ratios), gate specific check rules, and isolate exceptions.

03_understanding_rule_findings.ipynb
View Source

Target Leakage & Modeling Pipelines

Set up pre-modeling filters to automatically detect and prune target leakage features before passing variables to estimators.

04_data_science_workflows.ipynb
View Source

Ready to inspect performance?

Review Featuresmith's loading, profiling, and rule engine benchmarks.

View Benchmarks
featuresmith

Open-source data profiling and validation for Python engineers.

Documentation

  • Introduction
  • Quick Start
  • Python SDK
  • CLI Reference

Community

  • GitHub
  • Discussions
  • Issues
  • Contributing

Project

  • Roadmap
  • Release status
  • Benchmarks
  • Changelog
  • Examples

Legal

  • Apache 2.0 License
  • Code of Conduct
  • Security

© 2026 Featuresmith Contributors. Released under the Apache 2.0 License.

Built in the open — contributions welcome.