{"id":27259518,"url":"https://github.com/mohammadreza-mohammadi94/project-packaging-python-ml","last_synced_at":"2025-04-11T04:06:04.145Z","repository":{"id":286296709,"uuid":"960983748","full_name":"mohammadreza-mohammadi94/Project-Packaging-Python-ML","owner":"mohammadreza-mohammadi94","description":"This repository demonstrates how to package a simple Machine Learning project using Python’s standard packaging structure. It includes training a basic ML model and preparing it as an installable Python package that can be easily reused in other projects.","archived":false,"fork":false,"pushed_at":"2025-04-05T15:33:00.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T04:06:00.365Z","etag":null,"topics":["iris-classification","iris-dataset","project-management","project-packaging","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mohammadreza-mohammadi94.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-05T13:59:32.000Z","updated_at":"2025-04-05T15:33:03.000Z","dependencies_parsed_at":"2025-04-05T15:36:58.154Z","dependency_job_id":null,"html_url":"https://github.com/mohammadreza-mohammadi94/Project-Packaging-Python-ML","commit_stats":null,"previous_names":["mohammadreza-mohammadi94/project-packaging-python-ml"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammadreza-mohammadi94%2FProject-Packaging-Python-ML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammadreza-mohammadi94%2FProject-Packaging-Python-ML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammadreza-mohammadi94%2FProject-Packaging-Python-ML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mohammadreza-mohammadi94%2FProject-Packaging-Python-ML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mohammadreza-mohammadi94","download_url":"https://codeload.github.com/mohammadreza-mohammadi94/Project-Packaging-Python-ML/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339281,"owners_count":21087215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iris-classification","iris-dataset","project-management","project-packaging","python"],"created_at":"2025-04-11T04:06:03.503Z","updated_at":"2025-04-11T04:06:04.117Z","avatar_url":"https://github.com/mohammadreza-mohammadi94.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Iris Packaging Demo\n\n![Python](https://img.shields.io/badge/python-3.8+-blue.svg)\n![License](https://img.shields.io/badge/license-MIT-green.svg)\n![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)\n\nA Python package demonstrating how to structure, build, and package a machine learning project using modern tools like `pyproject.toml` and `build`. This project implements a Random Forest classifier for the Iris dataset, with features like data preprocessing, model training, evaluation, and model persistence.\n\n---\n\n## Table of Contents\n- [Purpose](#purpose)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Project Structure](#project-structure)\n- [Packaging Workflow](#packaging-workflow)\n- [Running Tests](#running-tests)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Purpose\nThis repository serves as a practical example of packaging a machine learning project in Python. It showcases:\n- How to structure a Python package with multiple modules.\n- Using `pyproject.toml` for modern package configuration.\n- Building and distributing the package with `build` and `wheel`.\n- Best practices for testing and documentation.\n\nThe project uses the famous Iris dataset and a Random Forest classifier as a real-world ML example.\n\n---\n\n## Features\n- **Data Preprocessing**: Handles missing values and scales features using `StandardScaler`.\n- **Model Training**: Implements a Random Forest classifier with configurable hyperparameters.\n- **Evaluation**: Provides accuracy and detailed classification metrics.\n- **Model Persistence**: Save and load trained models using `joblib`.\n- **Tests**: Includes unit tests with `pytest`.\n\n---\n\n## Installation\n\n### Prerequisites\n- Python 3.8 or higher\n- `pip` or `conda` for package management\n\n### Install from Source\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/yourusername/iris-packaging-demo.git\n   cd iris-packaging-demo\n   ```\n2. Install the package:\n   ```bash\n   pip install .\n   ```\n\n### Install from Wheel (Pre-built)\nIf you’ve built the package locally:\n```bash\npip install dist/iris_classifier-0.1.0-py3-none-any.whl\n```\n\n---\n\n## Usage\n\nHere’s a quick example of how to use the package:\n\n```python\nfrom iris_classifier import DataProcessor, IrisClassifier, split_data\n\n# Load and preprocess data\nprocessor = DataProcessor()\nX, y = processor.load_data()\nX_processed = processor.preprocess(X)\n\n# Split data into train and test sets\nX_train, X_test, y_train, y_test = split_data(X_processed, y)\n\n# Train the model\nmodel = IrisClassifier(n_estimators=100)\nmodel.fit(X_train, y_train)\n\n# Evaluate the model\nmetrics = model.evaluate(X_test, y_test)\nprint(\"Accuracy:\", metrics[\"accuracy\"])\nprint(\"Report:\\n\", metrics[\"report\"])\n\n# Save the model\n露\n\n# Load and use a saved model\nloaded_model = IrisClassifier.load(\"iris_model.pkl\")\n```\n\n**Expected Output:**\n```\nAccuracy: 0.9666666666666667\nReport:\n               precision    recall  f1-score   support\n      setosa       1.00      1.00      1.00        10\n  versicolor       0.90      1.00      0.95         9\n   virginica       1.00      0.91      0.95        11\n```\n\n---\n\n## Project Structure\n\n```\niris-packaging-demo/\n├── iris_classifier/        # Main package directory\n│   ├── __init__.py\n│   ├── data.py           # Data loading and preprocessing\n│   ├── model.py          # Model definition and training\n│   └── utils.py          # Utility functions\n├── tests/                 # Test directory\n│   ├── __init__.py\n│   └── test_model.py     # Unit tests\n├── pyproject.toml         # Package configuration\n├── README.md              # This file\n└── LICENSE                # License file (MIT)\n```\n\n---\n\n## Packaging Workflow\n\nTo build and package this project locally:\n\n1. **Install build tools**:\n   ```bash\n   pip install build setuptools wheel\n   ```\n\n2. **Build the package**:\n   ```bash\n   python -m build\n   ```\n   This generates `.tar.gz` and `.whl` files in the `dist/` directory.\n\n3. **Install the built package**:\n   ```bash\n   pip install dist/iris_classifier-0.1.0-py3-none-any.whl\n   ```\n\n---\n\n## Running Tests\n\nTo run the unit tests:\n\n1. **Install test dependencies**:\n   ```bash\n   pip install -e \".[test]\"\n   ```\n\n2. **Run tests**:\n   ```bash\n   pytest tests/\n   ```\n\n---\n\n## Contributing\n\nContributions are welcome! To contribute:\n1. Fork the repository.\n2. Create a new branch (`git checkout -b feature/your-feature`).\n3. Commit your changes (`git commit -m \"Add your feature\"`).\n4. Push to your branch (`git push origin feature/your-feature`).\n5. Open a Pull Request.\n\nPlease ensure your code follows PEP 8 style guidelines and includes tests.\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadreza-mohammadi94%2Fproject-packaging-python-ml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohammadreza-mohammadi94%2Fproject-packaging-python-ml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadreza-mohammadi94%2Fproject-packaging-python-ml/lists"}