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

Getting Started

  • Introduction
  • Installation
  • Quick Start
  • Benchmarks
  • Development Setup
  • Contributing

Core Concepts

  • Architecture Overview
  • Dataset Layer
  • Connectors
  • Profiling Engine
  • Rule Engine

Python SDK

  • load()
  • profile()
  • analyze()
  • Data Models
  • Exceptions
  • Plugins

CLI Reference

  • analyze
  • Configuration

Guides

  • CI/CD Integration
  • Custom Rules
  • Writing Plugins

Resources

  • Release Notes
  • FAQ
  • Troubleshooting
DocsGuide

Getting Started

  • Introduction
  • Installation
  • Quick Start
  • Benchmarks
  • Development Setup
  • Contributing

Core Concepts

  • Architecture Overview
  • Dataset Layer
  • Connectors
  • Profiling Engine
  • Rule Engine

Python SDK

  • load()
  • profile()
  • analyze()
  • Data Models
  • Exceptions
  • Plugins

CLI Reference

  • analyze
  • Configuration

Guides

  • CI/CD Integration
  • Custom Rules
  • Writing Plugins

Resources

  • Release Notes
  • FAQ
  • Troubleshooting
HomeDocsCustom Rules Guide

Guides

Custom Rules Guide

Learn how to write custom deterministic data quality validation rules

Featuresmith is fully extensible. You can easily add your own deterministic rules by extending the BaseRule interface and defining rule parameters.

The BaseRule Interface

All rules must extend BaseRule and implement the following properties and methods:

  • id: A unique dotted identifier (e.g., statistical.zero_variance).
  • name: A descriptive rule title.
  • category: Group category (e.g., quality, statistical, leakage).
  • severity: Finding severity level (e.g., RuleSeverity.INFO, WARNING, or CRITICAL).
  • evaluate(profile: ProfileResult) -> list[RuleFinding]: Core audit logic.

Custom Rule Implementation

Here is a complete example of a rule to detect numerical columns that have zero standard deviation (constant value columns):

python
1from typing import Any
2from featuresmith.rules.base import BaseRule
3from featuresmith.core.rule_finding import RuleFinding, RuleSeverity
4from featuresmith.core.profile_result import ProfileResult
5
6class ZeroVarianceRule(BaseRule):
7 """Custom rule to detect columns with zero variance."""
8
9 def __init__(self, **kwargs: Any) -> None:
10 super().__init__()
11 self.enabled = kwargs.get("enabled", True)
12
13 @property
14 def id(self) -> str:
15 return "statistical.zero_variance"
16
17 @property
18 def name(self) -> str:
19 return "Zero Variance Columns"
20
21 @property
22 def category(self) -> str:
23 return "statistical"
24
25 @property
26 def severity(self) -> RuleSeverity:
27 return RuleSeverity.WARNING
28
29 def evaluate(self, profile: ProfileResult) -> list[RuleFinding]:
30 findings = []
31 for col_name, col_profile in profile.column_profiles.items():
32 numeric_stats = col_profile.numeric_stats
33 if numeric_stats is not None and numeric_stats.std == 0.0:
34 findings.append(
35 self.create_finding(
36 column_name=col_name,
37 title="Zero Variance Detected",
38 description=f"Column '{col_name}' has standard deviation of 0.0 (no variance).",
39 evidence={"std": 0.0}
40 )
41 )
42 return findings

Evaluating Custom Rules

You can instantiate your rule and run it directly in Python:

python
1import featuresmith as fs
2
3dataset = fs.load("data.csv")
4rule = ZeroVarianceRule()
5
6# Run rule directly against computed statistical profiles
7profile = fs.profile(dataset)
8findings = rule.evaluate(profile)
9
10for finding in findings:
11 print(f"[{finding.severity}] {finding.title} in {finding.column_name}")

Explore

  • Quick Start
  • Python SDK
  • CLI Reference
  • Examples
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.