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

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
df['target'] = df['binaryClass'].apply(lambda x: 1 if x == "P" else 0) # target musts be numerical
# All feature columns
cols=[]
for col in df.columns:
    if col != 'binaryClass' and col != 'target':
        cols.append(col)
# Initialize
randomForest = RandomForestRules()
# Load data
randomForest.load_pandas(df)
# Fit
randomForest.fit(antecedents = cols, consequent = 'target', 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.1.tar.gz (4.8 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