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


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
for col in df.columns:
    if col != 'binaryClass' and col != 'target':
# Initialize
randomForest = RandomForestRules()
# Load data
# Fit = 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.

Files for randomForestRules-lukassykora, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size randomForestRules_lukassykora-1.1.1-py3-none-any.whl (5.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size randomForestRules-lukassykora-1.1.1.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page