CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-scikit-learn-intelex

Intel Extension for Scikit-learn providing hardware-accelerated implementations of scikit-learn algorithms optimized for Intel CPUs and GPUs.

Pending
Overview
Eval results
Files

daal4py-mb.mddocs/

Model Builder API (daal4py.mb)

Utility functions for converting external gradient boosting models (XGBoost, LightGBM, CatBoost) into Intel oneDAL format for accelerated inference. This API enables users to leverage Intel hardware optimizations on models trained with other frameworks.

Core Imports

from daal4py.mb import GBTDAALBaseModel, convert_model

Capabilities

Model Conversion

Convert external gradient boosting models to Intel oneDAL format for accelerated inference.

def convert_model(model):
    """
    Convert external gradient boosting model to Intel oneDAL format.
    
    Automatically detects model type and converts to appropriate oneDAL model
    for accelerated inference with Intel optimizations.
    
    Parameters:
        model: External model instance (XGBoost, LightGBM, or CatBoost)
               Supported types:
               - xgboost.sklearn.XGBClassifier/XGBRegressor  
               - xgboost.core.Booster
               - lightgbm.sklearn.LGBMClassifier/LGBMRegressor
               - lightgbm.basic.Booster
               - catboost.core.CatBoostClassifier/CatBoostRegressor
               - catboost.core.CatBoost
    
    Returns:
        Converted oneDAL model with Intel acceleration for inference
        
    Raises:
        TypeError: If model type is not supported
        
    Example:
        import xgboost as xgb
        from daal4py.mb import convert_model
        
        # Train XGBoost model
        xgb_model = xgb.XGBClassifier(n_estimators=100)
        xgb_model.fit(X_train, y_train)
        
        # Convert to Intel oneDAL format
        daal_model = convert_model(xgb_model)
        
        # Use accelerated inference
        predictions = daal_model.predict(X_test)
    """

class GBTDAALBaseModel:
    """
    Base class for gradient boosting tree models converted to Intel oneDAL format.
    
    Provides common functionality for converted GBT models including parameter
    extraction, model conversion, and accelerated inference methods.
    
    Attributes:
        model_type: Type of original model ('xgboost', 'lightgbm', 'catboost', or None)
        n_classes_: Number of classes for classification models
        n_features_in_: Number of input features
        daal_model_: Internal oneDAL model object
    """
    
    def __init__(self):
        """Initialize base model converter."""

Usage Examples

Converting XGBoost Models

import xgboost as xgb
from daal4py.mb import convert_model
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split

# Generate sample data
X, y = make_classification(n_samples=1000, n_features=20, n_classes=2, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Train XGBoost classifier
xgb_model = xgb.XGBClassifier(
    n_estimators=100,
    max_depth=6,
    learning_rate=0.1,
    random_state=42
)
xgb_model.fit(X_train, y_train)

# Convert to Intel oneDAL format for accelerated inference
daal_model = convert_model(xgb_model)

# Use accelerated inference
predictions = daal_model.predict(X_test)
probabilities = daal_model.predict_proba(X_test) if hasattr(daal_model, 'predict_proba') else None

print(f"Converted model type: {daal_model.model_type}")
print(f"Number of features: {daal_model.n_features_in_}")
print(f"Number of classes: {daal_model.n_classes_}")

Converting LightGBM Models

import lightgbm as lgb
from daal4py.mb import convert_model

# Train LightGBM regressor  
lgb_model = lgb.LGBMRegressor(
    n_estimators=100,
    learning_rate=0.1,
    num_leaves=31,
    random_state=42
)
lgb_model.fit(X_train, y_train)

# Convert to Intel oneDAL format
daal_model = convert_model(lgb_model)

# Accelerated inference
predictions = daal_model.predict(X_test)

Converting CatBoost Models

from catboost import CatBoostClassifier
from daal4py.mb import convert_model

# Train CatBoost classifier
cb_model = CatBoostClassifier(
    iterations=100,
    learning_rate=0.1,
    depth=6,
    verbose=False,
    random_state=42
)
cb_model.fit(X_train, y_train)

# Convert to Intel oneDAL format
daal_model = convert_model(cb_model)

# Accelerated inference
predictions = daal_model.predict(X_test)

Supported Model Types

XGBoost

  • xgboost.sklearn.XGBClassifierGBTDAALClassifier
  • xgboost.sklearn.XGBRegressorGBTDAALRegressor
  • xgboost.core.BoosterGBTDAALModel

LightGBM

  • lightgbm.sklearn.LGBMClassifierGBTDAALClassifier
  • lightgbm.sklearn.LGBMRegressorGBTDAALRegressor
  • lightgbm.basic.BoosterGBTDAALModel

CatBoost

  • catboost.core.CatBoostClassifierGBTDAALClassifier
  • catboost.core.CatBoostRegressorGBTDAALRegressor
  • catboost.core.CatBoostGBTDAALModel

Performance Benefits

  • Accelerated Inference: Up to 10-100x faster prediction on Intel hardware
  • Memory Efficiency: Optimized memory layout for Intel architectures
  • Threading: Automatic parallelization for multi-core systems
  • Vectorization: Intel SIMD optimizations for numerical computations

Limitations

  • Model conversion is one-way (cannot convert back to original format)
  • Training must be performed with original frameworks
  • Only gradient boosting tree models are supported
  • Converted models maintain prediction accuracy but may have slight numerical differences

Install with Tessl CLI

npx tessl i tessl/pypi-scikit-learn-intelex

docs

advanced.md

clustering.md

daal4py-mb.md

decomposition.md

ensemble.md

index.md

linear-models.md

metrics-model-selection.md

neighbors.md

patching-config.md

stats-manifold.md

svm.md

tile.json