Skip to main content

PrevhClassifier

This package implements the Prevh classification algorithm.

The algorithm is based in the follow research Pages 71-76.

Package Documentation.

Publish to PyPI and TestPyPI

User Guide

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

Python example:

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()

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.2.0 (27/09/2024)

MAJOR CHANGES

  • Update in the README.md
  • Added new R2, MSE, MAE metrics
  • Change in the confusion matrix plot function

Metadata

Release files for prevhlib 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prevhlib 0.2.0
File Size Uploaded Provenance Actions
prevhlib-0.2.0.tar.gz 22.1 kB Without provenance Details for prevhlib-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prevhlib 0.2.0
File Interpreter ABI Platform Actions
prevhlib-0.2.0-py3-none-any.whl Python 3 none any Details for prevhlib-0.2.0-py3-none-any.whl

Total release size: 45.0 kB

Release files / prevhlib-0.2.0.tar.gz

Download URL prevhlib-0.2.0.tar.gz
Size 22.1 kB
Tags Source
SHA-256 checksum
How to use checksums
506fbc1b4f9016cc0dbfa89fd8ed308a8391b9b3abd2618be09ffb6a8acfda39
BLAKE2b-256 checksum
How to use checksums
64ad747b2e96a5d310a669094ba4f710588bf920758763f907024f21c05ac8b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Release files / prevhlib-0.2.0-py3-none-any.whl

Download URL prevhlib-0.2.0-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d42bddac5c45e2b5de32edd8f59cdddcf967d4aac2c93080f690170a71e3ea4
BLAKE2b-256 checksum
How to use checksums
1d452627ff86964b5c0c630b9e56702751ba883df3e883c67e3643e28a3389ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.20

Security for prevhlib 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page