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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0953e6d17143b48406060629d92f572793c859c3cd9a618a6c331b0d0f5b78c5 |
|
MD5 | dcd94a8277e58258355882002332ed99 |
|
BLAKE2b-256 | f4821e1509a9ffc090852e1c3ace9f53c4c9fea90f3fbe17baca4d4f53840308 |
Close
Hashes for randomForestRules_lukassykora-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c68f94705361d07e2a02d445541a99e6f56b626b4b1138f341ead9a5fc0d820b |
|
MD5 | 72c181242fed5d41adcbce5cc2b4cabe |
|
BLAKE2b-256 | 961fcfc55040441a8999c9a93e2ff9d344e3eda8d6d795e1ba3e4d911c7379bf |