A framework for scaling sparse and interpretable supervised and unsupervised ML methods to highdimensional problems.
Project description
Overview
backbone_learn
backbone_learn
Get started
Installation
ToDo: Define method
pip install bakbonelearn
Note: For ODT implementations, please follow the instructions described in the libary to compile CBC from source using coinbrew: https://github.com/D3MResearchGroup/odtlearn#cbcbinaries
Run simulations
poetry shell
python experiments/sparse_regression_script.py
python experiments/clustering_script.py
python experiments/decision_trees_script.py
Add your own implementation
This guide explains how to create your own Backbone algoritms. You would need to

Implement your own screening method by implementing calculate_utilities() function from

Implement your heuristic solver by implementing fit() and get_relevant_features() functions

Implement your exact sovler by implementing fit() and predict()

Implement a Custom Screening Method
First, create a subclass of ScreenSelectorBase and implement the calculate_utilities method. This method should compute utilities (or importances) for each feature based on your screening criteria.
class CustomScreenSelector(ScreenSelectorBase):
def calculate_utilities(self, X: np.ndarray, y: np.ndarray) > np.ndarray::
# Implement logic here to calculate feature utilities
 Implement a Custom Heuristic Method
Next, create a subclass of HeuristicSolverBase and implement the fit, model, and get_relevant_features methods. This solver fits a model to the data using a heuristic approach and identifies relevant features.
class CustomHeuristicSolver(HeuristicSolverBase):
def fit(self, X: np.ndarray, y: np.ndarray):
# Implement logic here to fit the heuristic model
# Store the fitted model in self._model
def get_relevant_variables(self, **kwargs)>
# Logic to identify and return relevant features
 Implement a Custom Exact Solver
Create a subclass of ExactSolverBase and implement the fit, model, and predict methods. This solver fits a model using an exact or more rigorous approach and makes predictions.
class CustomExactSolver(ExactSolverBase):
def fit(self, X: np.ndarray, y: np.ndarray):
# Logic to fit the exact model
# Store the fitted model in self._model
def predict(self, X: np.ndarray) > np.ndarray:
# Logic to make predictions using the fitted model
 Build Your Custom Backbone Algorithm
To create your own Backbone algorithm, you can inherit from the BackboneBase class and define your custom solvers. The set_solvers method allows you to specify the screen selector, exact solver, and heuristic solver.
Here's an example of how you can assemble a custom Backbone algorithm:
class CustomBackboneAlgorithm(BackboneBase):
def set_solvers(self, **kwargs):
# Extract parameters specific to each solver
parameter_1 = kwargs.get('parameter_1')
parameter_2 = kwargs.get('parameter_2')
# Initialize custom solvers with extracted parameters
self.screen_selector = CustomScreenSelector()
self.exact_solver = CustomExactSolver(parameter_1)
self.heuristic_solver = CustomHeuristicSolver(parameter_2)
# You coud always skip screen_selector and exact_solver by defining them None
self.screen_selector = None
self.exact_solver = None
In this example, CustomBackboneAlgorithm automatically inherits the fit and predict methods from BackboneBase. The set_solvers method is used to initialize the specific screen selector, exact solver, and heuristic solver. This method extracts the relevant parameters from kwargs which are passed during object initialization.
 Example Usage Here's how you can use the custom Backbone algorithm:
# Initialize with custom parameters
backbone_algorithm = CustomBackboneAlgorithm(alpha=0.5, beta=0.3, num_subproblems=3,...)
# Fit the model
backbone_algorithm.fit(X, y)
# Make predictions
predictions = backbone_algorithm.predict(X_new)
License
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
Hashes for backbone_learn0.1.0py3noneany.whl
Algorithm  Hash digest  

SHA256  a8a0e24400440c6d9445a8095777ed0ac152858e9dc431226937eeb369d777fe 

MD5  63edbbbcdd5ccff1cf83d794631754cb 

BLAKE2b256  08fc4005aae15776abb6bb426f2fab2bf77ccd27627079090b9553f6c38a3577 