AI Data Sanitizer
This tool sanitizes AI training data to prevent data leakage and ensure model fairness. It detects and removes sensitive information, such as personally identifiable information (PII), from the training data. This tool is useful for AI developers to ensure the privacy and security of their training data.
Installation
To install the required packages, run:
pip install pandas numpy scikit-learnUsage
To use the AI Data Sanitizer, run:
python ai_data_sanitizer.py --input-path input.csv --output-path output.csvReplace input.csv with the path to your training data file and output.csv with the desired path for the sanitized data file.
Source Code
import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
import argparse
def load_data(input_path):
try:
return pd.read_csv(input_path)
except Exception as e:
print(f"Error loading data: {e}")
return None
def detect_pii(data):
# Simple PII detection: email, phone number, SSN
pii_columns = []
for column in data.columns:
if data[column].astype(str).str.contains('@').any() or \
data[column].astype(str).str.contains('\d{3}-\d{3}-\d{4}').any() or \
data[column].astype(str).str.contains('\d{9}').any():
pii_columns.append(column)
return pii_columns
def anonymize_pii(data, pii_columns):
for column in pii_columns:
data[column] = data[column].apply(lambda x: '***' if isinstance(x, str) else np.nan)
return data
def normalize_data(data):
scaler = StandardScaler()
numerical_columns = data.select_dtypes(include=['int64', 'float64']).columns
data[numerical_columns] = scaler.fit_transform(data[numerical_columns])
return data
def sanitize_data(input_path, output_path):
data = load_data(input_path)
if data is None:
return
pii_columns = detect_pii(data)
data = anonymize_pii(data, pii_columns)
data = normalize_data(data)
data.to_csv(output_path, index=False)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='AI Data Sanitizer')
parser.add_argument('--input-path', required=True, help='Path to the training data file')
parser.add_argument('--output-path', required=True, help='Path to the sanitized data file')
args = parser.parse_args()
sanitize_data(args.input_path, args.output_path)README
AI Data Sanitizer
This tool sanitizes AI training data to prevent data leakage and ensure model fairness.
Installation
To install the required packages, run:
pip install pandas numpy scikit-learnUsage
To use the AI Data Sanitizer, run:
python ai_data_sanitizer.py --input-path input.csv --output-path output.csvReplace input.csv with the path to your training data file and output.csv with the desired path for the sanitized data file.
Community
Downloads
ยทยทยท
Rate this tool
No ratings yet โ be the first!
Details
- Tool Name
- ai_data_sanitizer
- Category
- AI Safety and Security
- Generated
- August 10, 2026
- Tests
- Passing โ
- Fix Loops
- 4
Quick Install
Clone just this tool:
git clone --depth 1 --filter=blob:none --sparse \ https://github.com/ptulin/autoaiforge.git cd autoaiforge git sparse-checkout set generated_tools/2026-08-10/ai_data_sanitizer cd generated_tools/2026-08-10/ai_data_sanitizer pip install -r requirements.txt 2>/dev/null || true python ai_data_sanitizer.py