Metadata-Version: 2.4
Name: retof
Version: 0.1.0
Summary: A lightweight automated machine learning library for tabular datasets
Author: Ilesh
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=2.0
Requires-Dist: numpy>=1.24
Requires-Dist: scikit-learn>=1.3
Requires-Dist: xgboost>=2.0
Requires-Dist: joblib>=1.3
Requires-Dist: matplotlib>=3.7
Requires-Dist: seaborn>=0.12
Requires-Dist: scipy>=1.10
Requires-Dist: statsmodels>=0.14
Requires-Dist: optuna>=3.0
Dynamic: license-file

# RETOF

**RETOF** is an automated machine learning library for tabular datasets.

It is designed to automate the machine learning workflow from **dataset analysis and preprocessing to model training, evaluation, visualization, hyperparameter tuning, meta-learning, model serialization, and prediction**.

* * *

## Features

-   Automatic dataset analysis
    
-   Automatic problem-type detection
    
-   Automatic preprocessing
    
-   Numeric feature handling
    
-   Categorical feature handling
    
-   Missing-value handling
    
-   Binary classification
    
-   Multiclass classification
    
-   Regression
    
-   Multiple classification models
    
-   Multiple regression models
    
-   Model evaluation
    
-   Model comparison
    
-   Hyperparameter tuning
    
-   Dataset visualization
    
-   Feature importance analysis
    
-   Model saving and loading
    
-   Raw-data prediction using saved models
    
-   Meta-learning
    
-   Meta-dataset generation
    
-   Model recommendation
    

* * *

## Installation

### Install from PyPI

    pip install retof

### Install from source

    git clone <repository-url>
    cd retof

Create a virtual environment:

    python -m venv .venv

Activate it on Windows:

    .venv\Scripts\activate

Activate it on Linux/macOS:

    source .venv/bin/activate

Install RETOF:

    pip install -e .

* * *

## Quick Start

    import retof
    
    model = retof.fit(
        "train.csv",
        target="Survived",
        tune=False
    )
    
    print(model.get_model_info())
    print(model.get_results())

RETOF automatically:

    Dataset
       ↓
    Analysis
       ↓
    Preprocessing
       ↓
    Problem Detection
       ↓
    Model Training
       ↓
    Evaluation
       ↓
    Best Model

* * *

## AutoML

The main interface is the `AutoML` class.

    import retof
    
    automl = retof.AutoML(
        tune=False,
        use_meta_learning=False
    )
    
    automl.fit(
        "train.csv",
        target_column="Survived"
    )

Retrieve model information:

    print(automl.get_model_info())

Retrieve results:

    print(automl.get_results())

* * *

## Classification

RETOF supports binary and multiclass classification.

Example:

    import retof
    
    model = retof.fit(
        "train.csv",
        target="Survived",
        tune=False
    )

String targets are supported:

    Low
    Neutral
    Confident

RETOF internally handles target encoding while preserving the original target labels for prediction.

* * *

## Regression

RETOF also supports regression problems.

    import retof
    
    model = retof.fit(
        "housing.csv",
        target="price",
        tune=False
    )

Regression metrics include:

-   R²
    
-   MSE
    
-   RMSE
    
-   MAE
    

* * *

## Supported Models

### Classification

RETOF supports multiple classification algorithms, including:

-   Logistic Regression
    
-   Decision Tree
    
-   Random Forest
    
-   Extra Trees
    
-   HistGradientBoosting
    
-   XGBoost
    
-   K-Nearest Neighbors
    

### Regression

RETOF supports multiple regression algorithms, including:

-   Linear Regression
    
-   Ridge Regression
    
-   Decision Tree Regressor
    
-   Random Forest Regressor
    
-   Extra Trees Regressor
    
-   HistGradientBoosting Regressor
    
-   XGBoost Regressor
    

* * *

## Model Evaluation

RETOF evaluates trained models automatically.

### Classification

-   Accuracy
    
-   F1 Macro
    
-   Precision
    
-   Recall
    

### Regression

-   R²
    
-   MSE
    
-   RMSE
    
-   MAE
    

Example:

    print(automl.get_results())

RETOF also provides model comparison through:

    automl.plot_models()

* * *

## Hyperparameter Tuning

Enable tuning with:

    automl = retof.AutoML(
        tune=True
    )

Then:

    automl.fit(
        "train.csv",
        target_column="Survived"
    )

RETOF selects the appropriate tuning process according to the problem type and model.

For faster experimentation:

    automl = retof.AutoML(
        tune=False
    )

* * *

## Data Visualization

RETOF provides automatic dataset visualization.

    automl.plot_data()

Model comparison:

    automl.plot_models()

Feature importance:

    automl.plot_feature_importance()

Visualization functionality includes:

-   Dataset distributions
    
-   Target distribution
    
-   Missing values
    
-   Feature relationships
    
-   Correlations
    
-   Model performance
    
-   Feature importance
    

* * *

## Prediction

After training:

    predictions = automl.predict(X)

For classification models supporting probability prediction:

    probabilities = automl.predict_proba(X)

* * *

## Save a Model

A trained RETOF model can be saved as a serialized model artifact.

    automl.save(
        "model.pkl"
    )

The saved artifact contains the required model and preprocessing information.

* * *

## Load a Model

Load a previously trained model:

    import retof
    
    model = retof.ModelManager.load_model(
        "model.pkl"
    )

Retrieve model information:

    print(model.get_model_info())

Predict using the loaded model:

    predictions = model.predict(X)

The preprocessing pipeline is restored together with the model.

This allows raw feature data to be passed directly to the loaded model without manually rebuilding the preprocessing pipeline.

* * *

## Meta-Learning

RETOF includes a meta-learning system for learning from previous machine learning experiments.

Enable meta-learning:

    import retof
    
    automl = retof.AutoML(
        tune=False,
        use_meta_learning=True
    )

Train the initial model:

    automl.fit(
        "train.csv",
        target_column="Survived"
    )

Add additional datasets:

    automl.add_dataset(
        "Iris.csv",
        "Species"
    )
    
    automl.add_dataset(
        "laptopData.csv",
        "Price"
    )
    
    automl.add_dataset(
        "train_and_test2.csv",
        "2urvived"
    )
    
    automl.add_dataset(
        "winemag-data_first150k.csv",
        "points"
    )

Build the meta-dataset:

    meta_dataset = automl.build_meta_dataset()
    
    print(
        "Meta-dataset size:",
        len(meta_dataset)
    )

* * *

## Meta Features

RETOF extracts dataset-level characteristics such as:

-   Number of samples
    
-   Number of features
    
-   Number of numeric features
    
-   Number of categorical features
    
-   Missing-value ratio
    
-   Number of classes
    
-   Class imbalance
    
-   Problem type
    

These characteristics are stored together with experiment results.

A meta-record contains information such as:

    {
        "meta_features": {...},
        "best_model_name": "...",
        "best_params": {...},
        "evaluation_results": {...}
    }

* * *

## Complete Example

    import retof
    
    automl = retof.AutoML(
        tune=False,
        use_meta_learning=False
    )
    
    automl.fit(
        "train.csv",
        target_column="Survived"
    )
    
    print("\nMODEL INFORMATION")
    print(automl.get_model_info())
    
    print("\nMODEL RESULTS")
    print(automl.get_results())
    
    print("\nVISUALIZATIONS")
    
    automl.plot_data()
    automl.plot_models()
    automl.plot_feature_importance()
    
    automl.save(
        "model.pkl"
    )

Load the model:

    loaded_model = retof.ModelManager.load_model(
        "model.pkl"
    )
    
    print(
        loaded_model.get_model_info()
    )

Predict:

    predictions = loaded_model.predict(X)
    
    print(predictions)

* * *

## Complete Meta-Learning Example

    import retof
    
    automl = retof.AutoML(
        tune=False,
        use_meta_learning=True
    )
    
    automl.fit(
        "train.csv",
        target_column="Survived"
    )
    
    automl.add_dataset(
        "Iris.csv",
        "Species"
    )
    
    automl.add_dataset(
        "laptopData.csv",
        "Price"
    )
    
    automl.add_dataset(
        "train_and_test2.csv",
        "2urvived"
    )
    
    automl.add_dataset(
        "winemag-data_first150k.csv",
        "points"
    )
    
    meta_dataset = automl.build_meta_dataset()
    
    print(
        "Meta-dataset size:",
        len(meta_dataset)
    )
    
    for index, record in enumerate(meta_dataset, 1):
        print(f"\nDataset {index}")
    
        print(
            "Meta features:",
            record["meta_features"]
        )
    
        print(
            "Best model:",
            record["best_model_name"]
        )

* * *

## Architecture

RETOF is organized into separate modules.

    src/
    └── retof/
        ├── automl/
        │   ├── __init__.py
        │   └── AutoML.py
        │
        ├── data/
        │   ├── __init__.py
        │   ├── DataPreprocessor.py
        │   ├── DataVisualizer.py
        │   └── ejik.py
        │
        ├── experiments/
        │   ├── __init__.py
        │   └── ExperimentRunner.py
        │
        ├── meta/
        │   ├── __init__.py
        │   ├── MetaLearner.py
        │   └── MetadatasetBuilder.py
        │
        ├── models/
        │   ├── __init__.py
        │   ├── HyperparameterTuner.py
        │   ├── ModelEvaluator.py
        │   ├── ModelManager.py
        │   └── ModelTrain.py
        │
        └── utils/
            ├── __init__.py
            └── formatter.py

* * *

## Project Structure

    retof/
    │
    ├── src/
    │   └── retof/
    │       ├── automl/
    │       ├── data/
    │       ├── experiments/
    │       ├── meta/
    │       ├── models/
    │       └── utils/
    │
    ├── tests/
    │
    ├── README.md
    ├── LICENSE
    ├── .gitignore
    └── pyproject.toml

* * *

## Building RETOF

Install the build package:

    pip install build

Build the package:

    python -m build

The generated files will appear in:

    dist/

Example:

    dist/
    ├── retof-0.1.0.tar.gz
    └── retof-0.1.0-py3-none-any.whl

Install the generated wheel:

    pip install dist/retof-0.1.0-py3-none-any.whl

* * *

## Requirements

RETOF requires:

    Python >= 3.10

Core dependencies include:

-   numpy
    
-   pandas
    
-   scikit-learn
    
-   xgboost
    
-   joblib
    
-   matplotlib
    
-   seaborn
    
-   scipy
    
-   statsmodels
    
-   optuna
    

* * *

## Development Status

RETOF is currently in **alpha development**.

The API and internal implementation may change between releases.

* * *

## Roadmap

Future development may include:

-   More machine learning algorithms
    
-   Improved automatic model selection
    
-   More advanced meta-learning
    
-   Automated feature engineering
    
-   Improved hyperparameter optimization
    
-   Pipeline optimization
    
-   REST API deployment
    
-   Docker deployment
    
-   Cloud deployment
    
-   Distributed training
    
-   Automated experiment tracking
    
-   Additional dataset formats
    

* * *

## Contributing

Contributions, issues, and suggestions are welcome.

To contribute:

    git clone <repository-url>
    cd retof

Create a development environment:

    python -m venv .venv

Activate the environment and install RETOF:

    pip install -e .

Make your changes, add tests, and verify that the package builds successfully:

    python -m build
