Skip to main content

Random forest classification rules mining package

Project description

Random Forest Rules

License: MIT

Get the representation of all rules found by sklearn RandomForestClassifier. It works in following way:

  • On each feature, it applies one-hot encoding that makes each column binary.
  • Random Forest runs on the features and a target attribute.
  • All trees are extracted from the Random Forest Regressor.
  • Decision Trees are split to classification rules.

GIT repository

https://github.com/lukassykora/randomForestRules

Installation

pip install randomForestRules-lukassykora

Jupyter Notebook

Example

from randomForestRules import RandomForestRules
import pandas as pd

df = pd.read_csv("data/audiology.csv")
df.columns = df.columns.str.replace("_", "-") # underscore not allowed
# All feature columns
cols=[]
for col in df.columns:
    if col != 'binaryClass':
        cols.append(col)
# Initialize
randomForest = RandomForestRules()
# Load data
randomForest.load_pandas(df)
# Fit
randomForest.fit(antecedent = cols, consequent = 'binaryClass', supp=0.005, conf=50)
# Get result
frame = randomForest.get_frame()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

randomForestRules-lukassykora-1.1.2.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page