Skip to main content

Machine learning-specific feature engineering utilities including models and evaluation tools.

Project description

dsr-feature-eng-ml

Comprehensive machine learning model evaluation and feature engineering framework.

Features

  • Model Evaluation: Automatic hyperparameter tuning and model comparison for Decision Trees, Random Forests, and Logistic Regression
  • Data Balancing: Support for imbalanced dataset handling (upsampling, downsampling, balanced class weights)
  • Feature Importance: Automatic feature selection and importance ranking
  • Data Splitting: Intelligent train/validation/test splitting with automatic feature scaling
  • Result Tracking: Comprehensive model configuration and performance metrics tracking

Installation

pip install dsr-feature-eng-ml

Quick Start

import pandas as pd
from dsr_feature_eng_ml import DataSplits, ModelEvaluation

# Load your data
df = pd.read_csv('data.csv')

# Create data splits (with automatic scaling)
data_splits = DataSplits.from_data_source(
    src=df,
    features_to_include=['feature1', 'feature2', 'feature3'],
    target_column='target',
    test_size=0.2,
    valid_size=0.25,
    random_state=42,
    scale_features=True
)

# Evaluate models
results = ModelEvaluation.evaluate_dataset(
    data_splits=data_splits,
    dtree_param_grid={'max_depth': [5, 10, 20]},
    rf_param_grid={'n_estimators': [50, 100]},
    lr_param_grid={'C': [0.1, 1.0, 10.0]},
    cv=5,
    n_iter=50,
    max_iter=1000,
    scoring='f1',
    n_jobs=-1,
    viable_f1_gap=0.01,
    report_title='Model Evaluation',
    perform_dtree_feature_selection=True,
    perform_rf_feature_selection=True
)

Key Components

DataSplits

Manages train/validation/test splits with automatic feature scaling:

  • Fits scaler on training data only (prevents data leakage)
  • Transforms validation and test sets consistently
  • Supports upsampling and downsampling for class imbalance

ModelEvaluation

Orchestrates comprehensive model evaluation:

  • Evaluates multiple model types in parallel
  • Supports four balancing strategies
  • Tracks best performing models
  • Generates detailed evaluation reports

Model Classes

  • DecisionTree: Decision Tree classifier with feature importance
  • RandomForest: Random Forest classifier with ensemble methods
  • LogisticRegression: Logistic Regression with convergence control

Requirements

  • Python >= 3.9
  • pandas
  • numpy
  • scikit-learn >= 1.0
  • dsr-data-tools
  • dsr-utils

Architecture

The library uses a modular approach:

  • evaluation/: Core evaluation pipeline (DataSplits, ModelEvaluation, ModelResults)
  • models/: Model implementations and hyperparameter tuning
  • enums.py: Enumeration types for model states and configurations
  • constants.py: Global configuration and defaults

License

MIT License - see LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dsr_feature_eng_ml-0.0.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dsr_feature_eng_ml-0.0.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file dsr_feature_eng_ml-0.0.1.tar.gz.

File metadata

  • Download URL: dsr_feature_eng_ml-0.0.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for dsr_feature_eng_ml-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0470c81124bfd1f709b3ffc4520ce5733779d804f1fa2a1cb3fb13ec46734cea
MD5 c442bd4fd29585f610c52f55b6dc9a87
BLAKE2b-256 e1c457b1278bbc0643ced612f6e1af5e21bfa189685a09347ed5042749d9fe0a

See more details on using hashes here.

File details

Details for the file dsr_feature_eng_ml-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dsr_feature_eng_ml-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a777e66f53f5d51537bac29a13fea5e8a116b7d3ec197942133293f0a3bb3157
MD5 9ab82e689af1db2c2b239d8fa9e1bba6
BLAKE2b-256 cbcf805e9c51b198e53d0918ae656afd00077f84e3827c2d8f655a8b6923eaab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page