A Python package that generates code templates for ML lab questions - HTtoHP
Project description
HTtoHP - ML Lab Code Generator
A Python package that generates clean, well-formatted code templates for Machine Learning lab questions. This package does NOT execute ML code, but instead returns Python/ML code as strings that can be used as templates or starting points for ML assignments.
🎯 Features
- 8 Complete Sets of ML lab questions covering fundamental topics
- Python & ML Code Generation for each set
- Dynamic Templates with customizable parameters
- Clean, Ready-to-Execute Code with proper imports and structure
- Educational Focus - perfect for learning and teaching ML concepts
- Easy Installation via pip
📦 Installation
From PyPI (Recommended)
pip install HTtoHP
From Source
git clone https://github.com/yourusername/HTtoHP.git
cd HTtoHP
pip install .
Development Installation
git clone https://github.com/yourusername/HTtoHP.git
cd HTtoHP
pip install -e .
🚀 Quick Start
import HTtoHP
# Get code for SET 1 Machine Learning question
ml_code = HTtoHP.get_code(1, "ml")
print(ml_code)
# Get code for SET 3 Python question
python_code = HTtoHP.get_code(3, "python")
print(python_code)
# Save code to a file
file_path = HTtoHP.save_code_to_file(2, "ml", "my_regression.py")
print(f"Code saved to: {file_path}")
# List all available sets
sets_info = HTtoHP.list_available_sets()
for set_num, description in sets_info.items():
print(f"SET {set_num}: {description}")
📚 Available Sets
| Set | Python Topic | ML Topic |
|---|---|---|
| SET 1 | 2D Arrays & Indexing | Simple Linear Regression |
| SET 2 | 1D Arrays & Reversal | Multiple Linear Regression |
| SET 3 | Statistics & Boxplots | Binary Logistic Regression |
| SET 4 | Matrix Operations | Decision Tree |
| SET 5 | Matrix Creation & Slicing | Gradient Descent for Linear Regression |
| SET 6 | DataFrame & Missing Values | Logistic Regression |
| SET 7 | Line Plots & Labeling | K-Nearest Neighbors (KNN) |
| SET 8 | Scatter Plots & Styling | K-Means Clustering |
🔧 API Reference
Core Functions
get_code(set_number, part, **kwargs)
Generate code template for a specific set and part.
Parameters:
set_number(int): Set number (1-8)part(str): Either "python" or "ml"**kwargs: Additional parameters for dynamic templates
Returns: str - Generated code template
Example:
# Basic usage
code = HTtoHP.get_code(1, "ml")
# With custom parameters
code = HTtoHP.get_code(1, "ml",
dataset_name="iris.csv",
x_column="sepal_length",
y_column="sepal_width")
save_code_to_file(set_number, part, filename=None, **kwargs)
Save generated code to a Python file.
Parameters:
set_number(int): Set number (1-8)part(str): Either "python" or "ml"filename(str, optional): Output filename. Auto-generated if None.**kwargs: Additional parameters for dynamic templates
Returns: str - Path to the saved file
list_available_sets()
List all available sets and their descriptions.
Returns: dict - Dictionary with set numbers as keys and descriptions as values
🎨 Dynamic Templates
Many code templates support dynamic parameters:
import HTtoHP
# Customize dataset name and columns
ml_code = HTtoHP.get_code(2, "ml",
dataset_name="housing.csv",
target_column="price")
# Customize gradient descent parameters
gd_code = HTtoHP.get_code(5, "ml",
learning_rate=0.001,
iterations=2000)
# Customize matrix value
matrix_code = HTtoHP.get_code(1, "python", value=99)
📋 Example Usage
Generate and Execute ML Code
import HTtoHP
# Generate logistic regression code
log_reg_code = HTtoHP.get_code(6, "ml",
dataset_name="titanic.csv",
target_column="survived")
# Save to file
HTtoHP.save_code_to_file(6, "ml", "logistic_regression_analysis.py",
dataset_name="titanic.csv",
target_column="survived")
# The generated file is ready to run!
# python logistic_regression_analysis.py
Batch Generate All Sets
import HTtoHP
# Generate all Python questions
for set_num in range(1, 9):
code = HTtoHP.get_code(set_num, "python")
filename = f"set{set_num}_python.py"
HTtoHP.save_code_to_file(set_num, "python", filename)
print(f"Generated {filename}")
# Generate all ML questions
for set_num in range(1, 9):
code = HTtoHP.get_code(set_num, "ml")
filename = f"set{set_num}_ml.py"
HTtoHP.save_code_to_file(set_num, "ml", filename)
print(f"Generated {filename}")
🛠️ Development
Setting up Development Environment
# Clone the repository
git clone https://github.com/yourusername/HTtoHP.git
cd HTtoHP
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e .
# Install development dependencies
pip install -e .[dev]
Running Tests
pytest tests/
Code Formatting
black HTtoHP/
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📞 Support
If you encounter any problems or have questions, please:
- Check the documentation
- Search existing issues
- Create a new issue
🙏 Acknowledgments
- Built for educational purposes to help students learn Machine Learning
- Inspired by common ML lab assignments and best practices
- Uses popular ML libraries: scikit-learn, pandas, numpy, matplotlib
📊 Package Statistics
- 8 Sets of questions
- 16 Code templates (Python + ML for each set)
- Clean, documented code ready for execution
- Customizable parameters for dynamic templates
- Educational focus with detailed comments and explanations
Happy Learning! 🎓
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httohp-1.0.0.tar.gz.
File metadata
- Download URL: httohp-1.0.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73a05113af9f9cd6a34cc4e63a62d6eaf92180d9b720345340cd1863efe0325e
|
|
| MD5 |
e83d41ccb8d66e1f4bd0494d9c712ed2
|
|
| BLAKE2b-256 |
ea819766e956d87c15c63d574dfcfe82652db5a32526c59c84da5cdc71aa24df
|
File details
Details for the file httohp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: httohp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4357989f43b1bb2a2c92a205ce53a97e8f0cb688f16d602bec57e808c2c9f12f
|
|
| MD5 |
30bc73c1112fc1bc05cec9068c793f33
|
|
| BLAKE2b-256 |
7b1233013733668666bb81f4534251b216aec9401fd0dbebbc74304579eeec0f
|