Skip to main content

A library for hyperparameter tuning using grid search for machine learning models.

Project description

GridSearchHelper

A Python library to simplify hyperparameter tuning using scikit-learn's GridSearchCV. Automate parameter grid generation for various machine learning models and optimize your model's performance with ease.

PyPI version License: MIT Python 3.6+

🚀 Quick Start

pip install DridSearchHelper
from GridSearchHelper import get_param_grid, perform_grid_search
from sklearn.ensemble import RandomForestRegressor

# Initialize your model
model = RandomForestRegressor()

# Get parameter grid automatically
param_grid = get_param_grid(model)

# Perform grid search
best_params, best_score = perform_grid_search(model, param_grid, X_train, y_train)

🔑 Key Features

  • 🤖 Automatic Parameter Grid Generation: No more manual parameter grid definition
  • 🔄 Seamless scikit-learn Integration: Works directly with GridSearchCV
  • 📊 Multiple Model Support: Compatible with various scikit-learn models
  • 🛠 Easy to Use: Simple API with just two main functions

📋 Requirements

  • Python 3.6+
  • scikit-learn
  • numpy
  • pandas

💻 Installation

From PyPI

pip install gridsearchhelper

From Source

git clone https://github.com/alimovabdulla/GridSearchHelper.git
cd GridSearchHelper
pip install .

📖 Usage Examples

ElasticNet Example

from GridSearchHelper import get_param_grid, perform_grid_search
from sklearn.linear_model import ElasticNet
from sklearn.preprocessing import StandardScaler

# Prepare your model
model = ElasticNet(alpha=1)

# Scale your features
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)

# Get parameter grid and perform search
param_grid = get_param_grid(model)
best_params, best_score = perform_grid_search(model, param_grid, X_train_scaled, y_train)

RandomForest Example

from GridSearchHelper import get_param_grid, perform_grid_search
from sklearn.ensemble import RandomForestRegressor

# Initialize model
model = RandomForestRegressor()

# Get grid and optimize
param_grid = get_param_grid(model)
best_params, best_score = perform_grid_search(model, param_grid, X_train, y_train)

🛠 API Reference

get_param_grid(model)

Generates parameter grid based on model type.

Parameters:

  • model: scikit-learn model instance

Returns:

  • Dictionary containing parameter grid

perform_grid_search(model, param_grid, X_train, y_train)

Performs grid search with cross-validation.

Parameters:

  • model: scikit-learn model instance
  • param_grid: Parameter grid dictionary
  • X_train: Training features
  • y_train: Target values

Returns:

  • Tuple of (best_parameters, best_score)

🤝 Contributing

Contributions are welcome! Here's how you can help:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch (git checkout -b feature/amazing-feature)
  3. 💻 Make your changes
  4. 📝 Commit your changes (git commit -m 'Add amazing feature')
  5. 📤 Push to the branch (git push origin feature/amazing-feature)
  6. 🔄 Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

📞 Contact

Abdullah Alimov - @alimovabdulla

Project Link: https://github.com/alimovabdulla/GridSearchHelper

⭐️ Show your support

Give a ⭐️ if this project helped you!

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

GridSearchHelper-0.5.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

GridSearchHelper-0.5.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file GridSearchHelper-0.5.0.tar.gz.

File metadata

  • Download URL: GridSearchHelper-0.5.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for GridSearchHelper-0.5.0.tar.gz
Algorithm Hash digest
SHA256 f5092dd16a0b743a1f26df171facb6cff6d246564a0e01faa6c935374ef9dc07
MD5 16cc1ee92df4db51a4e95cd5518ab72b
BLAKE2b-256 c44102acfdfe56d41d1ca7e2e1c8b2da9811325773df619268b3152abf58cbb6

See more details on using hashes here.

File details

Details for the file GridSearchHelper-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for GridSearchHelper-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b2d2199f0a4ec781c7684b75a09c80b7555b137ced9457c641fc44b27e23679
MD5 1a3f6ed50038d1da5b1554f6785e544e
BLAKE2b-256 a144e2771cf6499142a13ebe9707cc71266bde719b23a653a7918b4f783a32c4

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