Random forest classification rules mining package
Project description
Random Forest Rules
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
Built Distribution
Close
Hashes for randomForestRules-lukassykora-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | af472defb8b278a13aa4fe98d54fe51662eb82c86edca6062e5b26250af744e0 |
|
MD5 | 8ad313559462dd630334db529ca1424a |
|
BLAKE2b-256 | d2aca264f69a07940d8db74df060ed32f65249f4bd6cd336324b9fbce53f038a |
Close
Hashes for randomForestRules_lukassykora-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8161b323f4541503d5bbb4916c6d69e11db747b5539b850decbfb45e779dce53 |
|
MD5 | f711282cce5c2aa41c4e6fd8bc2db5da |
|
BLAKE2b-256 | 0239813325ec9c1f8586ec00e2389bdda2371ed5caaa8910f2204ec58ef09405 |