Skip to main content

Build decision trees and random forests for classification and regression.

Project description

Description

Build random forests for classification and regression problems. The same program is available on CRAN for R users.

Installation

For Python:

python3 -m pip install brif

For R:

install.packages('brif')

Examples

import brif
import pandas as pd

# Create a brif object with default settings
bf = brif.brif()  

# Display the current parameter values. Parameter meanings are documented in the 'brif' package in R. 
bf.get_param()  

# To change certain parameter values, e.g.:
bf.set_param({'ntrees':100, 'nthreads':2})

# Or simply:
bf.ntrees = 200

# Load input data frame. Data must be a pandas data frame with appropriate headers.
# Header text and factor variable values must not contain any white space.
df = pd.read_csv("auto.csv")

# Train the model
bf.fit(df, 'origin')  # specify the target column name

# Or equivalently
bf.fit(df, 7)  # specify the target column index

# Make predictions 
# The target variable column must be excluded, and all other columns should appear in the same order as in training
# Here, predict the first 10 rows of df
pred_labels = bf.predict(df.iloc[0:10, 0:7], type='class')  # return a list containing the predicted class labels
pred_scores = bf.predict(df.iloc[0:10, 0:7], type='score')  # return a data frame containing predicted probabilities by class

# Note: for a regression problem (i.e., when the response variable is numeric type), the predict function will always return a list containing the predicted values

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

brif-1.2.0-cp310-cp310-win_amd64.whl (30.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

brif-1.2.0-cp38-cp38-macosx_10_9_x86_64.whl (40.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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