prevhlib


Nameprevhlib JSON
Version 0.1.6 PyPI version JSON
download
home_pagehttps://github.com/JCGCosta/Prevh
SummaryData Mining package implementing the PrevhClassifier algorithm.
upload_time2024-09-27 16:08:22
maintainerNone
docs_urlNone
authorJúlio César Guimarães Costa
requires_pythonNone
licenseGNU General Public License v3 (GPLv3)
keywords datamining
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PrevhClassifier
This package implements the Prevh classification algorithm.
> The algorithm is based in the follow [research](https://zenodo.org/record/6090322#.Yj98bKbMKUk) **Pages 71-76**.
 
> [Package Documentation](https://pypi.org/project/prevhlib/).

> [![Publish to PyPI and TestPyPI](https://github.com/JCGCosta/Prevh/actions/workflows/python-publish.yml/badge.svg)](https://github.com/JCGCosta/Prevh/actions/workflows/python-publish.yml)

# User Guide

> This package can be installed with the following command: **pip install prevhlib**

## Python example:

```python
import numpy as np
import pandas as pd
from __init__.PrevhClassifier import PrevhClassifier
from sklearn.preprocessing import StandardScaler, LabelEncoder

if __name__ == '__main__':
    iris = pd.read_csv('Datasets/iris.csv')

    X = iris.iloc[:, 0:4].values
    y = iris.iloc[:, 4].values
    header = (iris.columns[:-1], iris.columns[-1])

    prevh = PrevhClassifier(distance_algorithm="euclidean")
    prevh.fit(X, y, header=header, encoder=LabelEncoder(), scaler=StandardScaler())

    print(prevh)
    # Outputs: 
    # {  
    #    "dataset": {
    #       "header": {
    #          "features": "Index(['sepal length', 'sepal width', 'petal length', 'petal width'], dtype='object')",
    #          "classes": "class"
    #       },
    #       "encoder": "LabelEncoder()",
    #       "scaler": "StandardScaler()"
    #    },
    #    "distance": "euclidean"
    # }

    print(prevh.classify(np.array([5.1, 3.5, 1.4, 0.2]), K=3))
    # Outputs: (array(['Iris-setosa'], dtype=object), np.float64(0.2653212465045153))

    kfold_split_arguments = {
        "n_splits": 5,
        "random_state": 42,
        "shuffle": True
    }

    Evaluation_Results = prevh.evaluate(1, "kfold_cross_validation", kfold_split_arguments)

    print(Evaluation_Results.get_metrics())
    # Outputs:
    #       accuracy  precision    recall  f1-score
    # 0     0.966667   0.972222  0.962963  0.965899
    # 1     0.966667   0.969697  0.952381  0.958486
    # 2     0.966667   0.962963  0.966667  0.962848
    # 3     0.900000   0.911681  0.905556  0.907368
    # 4     0.966667   0.972222  0.972222  0.971014
    # Mean  0.953333   0.957757  0.951958  0.953123

    Evaluation_Results.plot_confusion_matrices()
```

<img src="https://raw.githubusercontent.com/JCGCosta/Prevh/refs/heads/main/confusion_matrix_example.png" width = "600">

## Next Steps

- In the next steps I will add support to other split, evaluation, encoder, and decoder methods.
- I expect to in new versions to comparisons between other machine learn method and the prevh classifier.


Change Log
===============
0.1.6 (27/09/2024)
------------------
MAJOR CHANGES
- Update in the README.md
- Update the required libraries for security reasons
- Change code structure to be more readable
- Added the Evaluator object, and metric plots
------------------



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JCGCosta/Prevh",
    "name": "prevhlib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "DataMining",
    "author": "J\u00falio C\u00e9sar Guimar\u00e3es Costa",
    "author_email": "juliocesargcosta123@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1b/e2/1a34e852491c4db6e1877b507d4f5e89a33a9281bb1db1cdb3fa9c2ca39a/prevhlib-0.1.6.tar.gz",
    "platform": null,
    "description": "# PrevhClassifier\nThis package implements the Prevh classification algorithm.\n> The algorithm is based in the follow [research](https://zenodo.org/record/6090322#.Yj98bKbMKUk) **Pages 71-76**.\n \n> [Package Documentation](https://pypi.org/project/prevhlib/).\n\n> [![Publish to PyPI and TestPyPI](https://github.com/JCGCosta/Prevh/actions/workflows/python-publish.yml/badge.svg)](https://github.com/JCGCosta/Prevh/actions/workflows/python-publish.yml)\n\n# User Guide\n\n> This package can be installed with the following command: **pip install prevhlib**\n\n## Python example:\n\n```python\nimport numpy as np\nimport pandas as pd\nfrom __init__.PrevhClassifier import PrevhClassifier\nfrom sklearn.preprocessing import StandardScaler, LabelEncoder\n\nif __name__ == '__main__':\n    iris = pd.read_csv('Datasets/iris.csv')\n\n    X = iris.iloc[:, 0:4].values\n    y = iris.iloc[:, 4].values\n    header = (iris.columns[:-1], iris.columns[-1])\n\n    prevh = PrevhClassifier(distance_algorithm=\"euclidean\")\n    prevh.fit(X, y, header=header, encoder=LabelEncoder(), scaler=StandardScaler())\n\n    print(prevh)\n    # Outputs: \n    # {  \n    #    \"dataset\": {\n    #       \"header\": {\n    #          \"features\": \"Index(['sepal length', 'sepal width', 'petal length', 'petal width'], dtype='object')\",\n    #          \"classes\": \"class\"\n    #       },\n    #       \"encoder\": \"LabelEncoder()\",\n    #       \"scaler\": \"StandardScaler()\"\n    #    },\n    #    \"distance\": \"euclidean\"\n    # }\n\n    print(prevh.classify(np.array([5.1, 3.5, 1.4, 0.2]), K=3))\n    # Outputs: (array(['Iris-setosa'], dtype=object), np.float64(0.2653212465045153))\n\n    kfold_split_arguments = {\n        \"n_splits\": 5,\n        \"random_state\": 42,\n        \"shuffle\": True\n    }\n\n    Evaluation_Results = prevh.evaluate(1, \"kfold_cross_validation\", kfold_split_arguments)\n\n    print(Evaluation_Results.get_metrics())\n    # Outputs:\n    #       accuracy  precision    recall  f1-score\n    # 0     0.966667   0.972222  0.962963  0.965899\n    # 1     0.966667   0.969697  0.952381  0.958486\n    # 2     0.966667   0.962963  0.966667  0.962848\n    # 3     0.900000   0.911681  0.905556  0.907368\n    # 4     0.966667   0.972222  0.972222  0.971014\n    # Mean  0.953333   0.957757  0.951958  0.953123\n\n    Evaluation_Results.plot_confusion_matrices()\n```\n\n<img src=\"https://raw.githubusercontent.com/JCGCosta/Prevh/refs/heads/main/confusion_matrix_example.png\" width = \"600\">\n\n## Next Steps\n\n- In the next steps I will add support to other split, evaluation, encoder, and decoder methods.\n- I expect to in new versions to comparisons between other machine learn method and the prevh classifier.\n\n\nChange Log\n===============\n0.1.6 (27/09/2024)\n------------------\nMAJOR CHANGES\n- Update in the README.md\n- Update the required libraries for security reasons\n- Change code structure to be more readable\n- Added the Evaluator object, and metric plots\n------------------\n\n\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3 (GPLv3)",
    "summary": "Data Mining package implementing the PrevhClassifier algorithm.",
    "version": "0.1.6",
    "project_urls": {
        "Homepage": "https://github.com/JCGCosta/Prevh"
    },
    "split_keywords": [
        "datamining"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "63e8cd714ed6ca37b4ac7e91a106be7a7f8b20754a0411e103f504a69f2a0d45",
                "md5": "0a4ccee51a924f314532e1b83f73616c",
                "sha256": "ca8103e2a9d1e08b64bdf81b7ad4e3f6d3d63ffd633a581ff02d6d45ad4e9f81"
            },
            "downloads": -1,
            "filename": "prevhlib-0.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0a4ccee51a924f314532e1b83f73616c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 22662,
            "upload_time": "2024-09-27T16:08:20",
            "upload_time_iso_8601": "2024-09-27T16:08:20.882166Z",
            "url": "https://files.pythonhosted.org/packages/63/e8/cd714ed6ca37b4ac7e91a106be7a7f8b20754a0411e103f504a69f2a0d45/prevhlib-0.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1be21a34e852491c4db6e1877b507d4f5e89a33a9281bb1db1cdb3fa9c2ca39a",
                "md5": "f79802e2d1496ecba5249272d26ee7a0",
                "sha256": "c5f933500988035c5066d08ac9eb52eaf034223db3a0b6bcd97bf34b5c5fb39c"
            },
            "downloads": -1,
            "filename": "prevhlib-0.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "f79802e2d1496ecba5249272d26ee7a0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 21863,
            "upload_time": "2024-09-27T16:08:22",
            "upload_time_iso_8601": "2024-09-27T16:08:22.270171Z",
            "url": "https://files.pythonhosted.org/packages/1b/e2/1a34e852491c4db6e1877b507d4f5e89a33a9281bb1db1cdb3fa9c2ca39a/prevhlib-0.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-27 16:08:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JCGCosta",
    "github_project": "Prevh",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "prevhlib"
}
        
Elapsed time: 0.79316s