Skip to content

Improve error handling and validation in Model initialization #79

@KumarManglam-123

Description

@KumarManglam-123

Feature Description

Currently, the Model initialization in etsi-etna does not consistently validate
user inputs such as file path existence, target column correctness, hidden layer
configuration, activation names, or optimizer parameters.

This feature proposes adding structured validation and clear error handling
during Model initialization to ensure:

• Invalid dataset paths raise meaningful FileNotFoundError
• Missing or incorrect target column raises ValueError
• Hidden layer configuration is validated (non-empty, positive integers)
• Unsupported activation or optimizer names raise clear exceptions
• Helpful error messages guide beginners toward correct usage

The goal is to make the library more robust, beginner-friendly, and production-safe.

Why is this needed?

Better validation and error handling significantly improve developer experience,
especially for beginners using Etna for the first time.

Current behavior may produce silent failures or unclear runtime errors,
which makes debugging difficult and reduces trust in the API.

Improving initialization validation will:

• Prevent invalid training runs early
• Provide clear, actionable feedback to users
• Align the library with best practices followed by scikit-learn and PyTorch
• Improve reliability for research and production workflows

This enhancement strengthens usability without affecting performance.

Implementation Plan

Planned steps:

  1. Add validation logic inside the Python Model constructor:
    • Check dataset file existence
    • Validate target column presence in dataset
    • Ensure hidden_layers is a list of positive integers
    • Validate activation and optimizer names against supported options

  2. Introduce descriptive exception messages for each failure case.

  3. Add unit tests in the tests/ directory covering:
    • Invalid file path
    • Missing target column
    • Invalid hidden layer values
    • Unsupported activation/optimizer

  4. Ensure backward compatibility with existing working code.

This change is limited to validation logic and will not modify
core Rust training performance.

Screenshots or Diagrams

No response

Assignment and Program Context

  • I want to be assigned to this issue.
  • I am contributing through the SWOC program.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew ML layers or API functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions