Giter Club home page Giter Club logo

l3wrapper's Introduction

l3wrapper

Latest PyPI version Documentation Status doi badge

A Python 3 wrapper around Live-and-Let-Live (L^3) classifier binaries implementing the scikit-learn estimator interface. The associative classifier was originally published in [1].

When imported, the package looks for L^3 compiled binaries in the user's $HOME directory. If they are not found, it downloads them. If you mind letting the wrapper do this for you, you can download the binaries for macOS Catalina or Ubuntu 18.04.

[1]Elena Baralis, Silvia Chiusano, and Paolo Garza. 2008. A Lazy Approach to Associative Classification. IEEE Trans. Knowl. Data Eng. 20, 2 (2008), 156โ€“171. https://doi.org/10.1109/TKDE.2007.190677

Installation

Install using pip with:

pip install l3wrapper

Or, download a wheel or source archive from PyPI.

Requirements

The package is dependent on numpy, scikit-learn, tqdm, and requests.

Usage

By design, the classifier is intended for categorical/discrete attributes. Therefore, using subtypes of numpy.number to fit the model is not allowed.

Simple classification

A sample usage with the Car Evaluation dataset:

>>> from l3wrapper.l3wrapper import L3Classifier
>>> import numpy as np
>>> from sklearn.model_selection import train_test_split
>>> from sklearn.metrics import accuracy_score
>>> X = np.loadtxt('car.data', dtype=object, delimiter=',')
>>> y = X[:, -1]
>>> X = X[:, :-1]
>>> X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
>>> clf = L3Classifier().fit(X_train, y_train)
>>> accuracy_score(y_test, clf.predict(X_test))
0.9071803852889667

Column names and interpretable rules

Use the column_names and save_human_readable parameters to obtain an interpretable representation of the model:

>>> column_names = ['buying', 'maint', 'doors', 'persons', 'lug_boot', 'safety']
>>> clf = L3Classifier().fit(X_train, y_train, column_names=column_names, save_human_readable=True)

The snippet will generate the level1 and level2 rule sets. An excerpt is:

0 persons:4,safety:high,maint:low,buying:high acc 12 100.0 4
1 doors:2,buying:vhigh,safety:med,lug_boot:med unacc 11 100.0 4

in the form:

<rule_id>\t<antecedent>\t<class label>\t<support count>\t<confidence(%)>\t<rule length>

Known limitations

  • fixed The parallel training of multiple models cause failures (e.g. using ``GridSearchCV``, ``joblib`` or custom parallelism through ``multiprocessing`` with ``njobs>1``).
  • The scikit-learn's utility check_estimator still doesn't work, as L3Classifier doesn't support numerical input.

Compatibility

The underlying L^3 binaries are currently available for macOS and Ubuntu.

The package is currently tested with Python 3.6+.

License

The MIT License.

Authors

l3wrapper was written by g8a9.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.