Name | openmodels JSON |
Version |
0.1.0a1
JSON |
| download |
home_page | None |
Summary | Export scikit-learn model files to JSON for sharing or deploying predictive models with peace of mind. |
upload_time | 2024-08-13 00:53:26 |
maintainer | None |
docs_url | None |
author | Alejandro Gutierrez |
requires_python | <4.0,>=3.9 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# OpenModels
[](https://badge.fury.io/py/openmodels)
[](https://opensource.org/licenses/MIT)
[](https://pypi.org/project/openmodels/)
OpenModels is a flexible and extensible library for serializing and deserializing machine learning models. It's designed to support any serialization format through a plugin-based architecture, providing a safe and transparent solution for exporting and sharing predictive models.
## Key Features
- **Format Agnostic**: Supports any serialization format through a plugin-based system.
- **Extensible**: Easily add support for new model types and serialization formats.
- **Safe**: Provides alternatives to potentially unsafe serialization methods like Pickle.
- **Transparent**: Supports human-readable formats for easy inspection of serialized models.
## Installation
```bash
pip install openmodels
```
## Quick Start
```python
from openmodels import SerializationManager, SklearnSerializer
from sklearn.ensemble import RandomForestClassifier
from sklearn.datasets import make_classification
# Create and train a scikit-learn model
X, y = make_classification(n_samples=1000, n_features=4, n_informative=2, n_redundant=0, random_state=0, shuffle=False)
model = RandomForestClassifier(n_estimators=10, max_depth=5, random_state=0)
model.fit(X, y)
# Create a SerializationManager
manager = SerializationManager(SklearnSerializer())
# Serialize the model (default format is JSON)
serialized_model = manager.serialize(model)
# Deserialize the model
deserialized_model = manager.deserialize(serialized_model)
# Use the deserialized model
predictions = deserialized_model.predict(X[:5])
print(predictions)
```
## Extensibility
OpenModels is designed to be easily extended with new serialization formats and model types.
### Adding a New Format
To add a new serialization format, create a class that implements the `FormatConverter` protocol and register it with the `FormatRegistry`:
```python
from openmodels.protocols import FormatConverter
from openmodels.format_registry import FormatRegistry
from typing import Dict, Any
class YAMLConverter(FormatConverter):
@staticmethod
def serialize_to_format(data: Dict[str, Any]) -> str:
import yaml
return yaml.dump(data)
@staticmethod
def deserialize_from_format(formatted_data: str) -> Dict[str, Any]:
import yaml
return yaml.safe_load(formatted_data)
FormatRegistry.register("yaml", YAMLConverter)
```
### Adding a New Model Serializer
To add support for a new type of model, create a class that implements the `ModelSerializer` protocol:
```python
from openmodels.protocols import ModelSerializer
from typing import Any, Dict
class TensorFlowSerializer(ModelSerializer):
def serialize(self, model: Any) -> Dict[str, Any]:
# Implementation for serializing TensorFlow models
...
def deserialize(self, data: Dict[str, Any]) -> Any:
# Implementation for deserializing TensorFlow models
...
```
## Supported Models
OpenModels currently supports a wide range of scikit-learn models, including:
- Classification: LogisticRegression, RandomForestClassifier, SVC, etc.
- Regression: LinearRegression, RandomForestRegressor, SVR, etc.
- Clustering: KMeans
- Dimensionality Reduction: PCA
For a full list of supported models, please refer to the `SUPPORTED_ESTIMATORS` dictionary in `serializers/sklearn_serializer.py`.
## Contributing
We welcome contributions to OpenModels! Whether you want to add support for new models, implement new serialization formats, or improve the existing codebase, your help is appreciated.
Please refer to our [Contributing Guidelines](CONTRIBUTING.md) for more information on how to get started.
## Running Tests
To run the tests:
1. Clone the repository:
```bash
git clone https://github.com/your-repo/openmodels.git
cd openmodels
```
2. Install the package and its dependencies:
```bash
pip install -e .
```
3. Run the tests:
```bash
pytest
```
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Changelog
For a detailed changelog, please see the [CHANGELOG.md](CHANGELOG.md) file.
## Support
If you encounter any issues or have questions, please [file an issue](https://github.com/SF-Tec/openmodels) on our GitHub repository.
We're always looking to improve OpenModels. If you have any suggestions or feature requests, please let us know!
Raw data
{
"_id": null,
"home_page": null,
"name": "openmodels",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Alejandro Gutierrez",
"author_email": "agutierrez@sftec.es>, Pau Cabaneros <pau.cabaneros@gmail.com>, Ra\u00fal Mar\u00edn <hi@raulmarin.dev>, Ruben Parrilla <rparrilla@sftec.es",
"download_url": "https://files.pythonhosted.org/packages/f8/a2/cdb36aa771fda91d44b3f3d02d9ccdf4bce557b6d1f1fd3450524961020a/openmodels-0.1.0a1.tar.gz",
"platform": null,
"description": "# OpenModels\n\n[](https://badge.fury.io/py/openmodels)\n[](https://opensource.org/licenses/MIT)\n[](https://pypi.org/project/openmodels/)\n\nOpenModels is a flexible and extensible library for serializing and deserializing machine learning models. It's designed to support any serialization format through a plugin-based architecture, providing a safe and transparent solution for exporting and sharing predictive models.\n\n## Key Features\n\n- **Format Agnostic**: Supports any serialization format through a plugin-based system.\n- **Extensible**: Easily add support for new model types and serialization formats.\n- **Safe**: Provides alternatives to potentially unsafe serialization methods like Pickle.\n- **Transparent**: Supports human-readable formats for easy inspection of serialized models.\n\n## Installation\n\n```bash\npip install openmodels\n```\n\n## Quick Start\n\n```python\nfrom openmodels import SerializationManager, SklearnSerializer\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.datasets import make_classification\n\n# Create and train a scikit-learn model\nX, y = make_classification(n_samples=1000, n_features=4, n_informative=2, n_redundant=0, random_state=0, shuffle=False)\nmodel = RandomForestClassifier(n_estimators=10, max_depth=5, random_state=0)\nmodel.fit(X, y)\n\n# Create a SerializationManager\nmanager = SerializationManager(SklearnSerializer())\n\n# Serialize the model (default format is JSON)\nserialized_model = manager.serialize(model)\n\n# Deserialize the model\ndeserialized_model = manager.deserialize(serialized_model)\n\n# Use the deserialized model\npredictions = deserialized_model.predict(X[:5])\nprint(predictions)\n```\n\n## Extensibility\n\nOpenModels is designed to be easily extended with new serialization formats and model types.\n\n### Adding a New Format\n\nTo add a new serialization format, create a class that implements the `FormatConverter` protocol and register it with the `FormatRegistry`:\n\n```python\nfrom openmodels.protocols import FormatConverter\nfrom openmodels.format_registry import FormatRegistry\nfrom typing import Dict, Any\n\nclass YAMLConverter(FormatConverter):\n @staticmethod\n def serialize_to_format(data: Dict[str, Any]) -> str:\n import yaml\n return yaml.dump(data)\n\n @staticmethod\n def deserialize_from_format(formatted_data: str) -> Dict[str, Any]:\n import yaml\n return yaml.safe_load(formatted_data)\n\nFormatRegistry.register(\"yaml\", YAMLConverter)\n```\n\n### Adding a New Model Serializer\n\nTo add support for a new type of model, create a class that implements the `ModelSerializer` protocol:\n\n```python\nfrom openmodels.protocols import ModelSerializer\nfrom typing import Any, Dict\n\nclass TensorFlowSerializer(ModelSerializer):\n def serialize(self, model: Any) -> Dict[str, Any]:\n # Implementation for serializing TensorFlow models\n ...\n\n def deserialize(self, data: Dict[str, Any]) -> Any:\n # Implementation for deserializing TensorFlow models\n ...\n```\n\n## Supported Models\n\nOpenModels currently supports a wide range of scikit-learn models, including:\n\n- Classification: LogisticRegression, RandomForestClassifier, SVC, etc.\n- Regression: LinearRegression, RandomForestRegressor, SVR, etc.\n- Clustering: KMeans\n- Dimensionality Reduction: PCA\n\nFor a full list of supported models, please refer to the `SUPPORTED_ESTIMATORS` dictionary in `serializers/sklearn_serializer.py`.\n\n## Contributing\n\nWe welcome contributions to OpenModels! Whether you want to add support for new models, implement new serialization formats, or improve the existing codebase, your help is appreciated.\n\nPlease refer to our [Contributing Guidelines](CONTRIBUTING.md) for more information on how to get started.\n\n## Running Tests\n\nTo run the tests:\n\n1. Clone the repository:\n\n ```bash\n git clone https://github.com/your-repo/openmodels.git\n cd openmodels\n ```\n\n2. Install the package and its dependencies:\n\n ```bash\n pip install -e .\n ```\n\n3. Run the tests:\n ```bash\n pytest\n ```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Changelog\n\nFor a detailed changelog, please see the [CHANGELOG.md](CHANGELOG.md) file.\n\n## Support\n\nIf you encounter any issues or have questions, please [file an issue](https://github.com/SF-Tec/openmodels) on our GitHub repository.\n\nWe're always looking to improve OpenModels. If you have any suggestions or feature requests, please let us know!\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Export scikit-learn model files to JSON for sharing or deploying predictive models with peace of mind.",
"version": "0.1.0a1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4c10ae033d4c1c977f7728b75ee70de29b5434dd7b5350922af9663151710282",
"md5": "79a7e929d1b33c7d776bd101669bb27f",
"sha256": "47887eca051afa8312877161b924aaa9a38be11c07edd14f68b14811ad625b24"
},
"downloads": -1,
"filename": "openmodels-0.1.0a1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "79a7e929d1b33c7d776bd101669bb27f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 14214,
"upload_time": "2024-08-13T00:53:23",
"upload_time_iso_8601": "2024-08-13T00:53:23.782707Z",
"url": "https://files.pythonhosted.org/packages/4c/10/ae033d4c1c977f7728b75ee70de29b5434dd7b5350922af9663151710282/openmodels-0.1.0a1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f8a2cdb36aa771fda91d44b3f3d02d9ccdf4bce557b6d1f1fd3450524961020a",
"md5": "59e6199a184ddd7a674b91257a9cc7b5",
"sha256": "0b22507fda4d2237ec47528e4354b572ab7e36b654c00b3e89ff89ecad70f569"
},
"downloads": -1,
"filename": "openmodels-0.1.0a1.tar.gz",
"has_sig": false,
"md5_digest": "59e6199a184ddd7a674b91257a9cc7b5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 11101,
"upload_time": "2024-08-13T00:53:26",
"upload_time_iso_8601": "2024-08-13T00:53:26.560902Z",
"url": "https://files.pythonhosted.org/packages/f8/a2/cdb36aa771fda91d44b3f3d02d9ccdf4bce557b6d1f1fd3450524961020a/openmodels-0.1.0a1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-13 00:53:26",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "openmodels"
}