Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Sdv dev SDV Inequality Init

From Leeroopedia
Knowledge Sources
Domains Data_Quality, Constraint_Satisfaction
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete tool for enforcing column ordering constraints in synthetic data generation, provided by the SDV library.

Description

The Inequality constraint ensures that values in high_column_name are always greater than (or equal to, depending on strict_boundaries) values in low_column_name. Supports both numerical and datetime columns.

Usage

Create an Inequality instance and add it to a synthesizer via add_constraints before fitting.

Code Reference

Source Location

  • Repository: SDV
  • File: sdv/cag/inequality.py
  • Lines: L27-74

Signature

class Inequality(BaseConstraint):
    def __init__(
        self,
        low_column_name,
        high_column_name,
        strict_boundaries=False,
        table_name=None,
    ):
        """
        Args:
            low_column_name (str): Column with lower values.
            high_column_name (str): Column with higher values.
            strict_boundaries (bool): Use > instead of >=. Defaults to False.
            table_name (str or None): Target table (multi-table). Defaults to None.
        """

Import

from sdv.cag import Inequality

I/O Contract

Inputs

Name Type Required Description
low_column_name str Yes Column containing the lower bound values
high_column_name str Yes Column containing the upper bound values
strict_boundaries bool No Use strict > comparison (default: False, uses >=)
table_name str or None No Target table for multi-table data (default: None)

Outputs

Name Type Description
instance Inequality Constraint object ready to add to a synthesizer

Usage Examples

from sdv.cag import Inequality

# Ensure end_date is always after start_date
constraint = Inequality(
    low_column_name='start_date',
    high_column_name='end_date',
    strict_boundaries=True,
)

synthesizer.add_constraints([constraint])
synthesizer.fit(data)

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment