Skip to content

Commit

Permalink
chore: move xgb import to occur at runtime (#135)
Browse files Browse the repository at this point in the history
move xgb import to occur at runtime
  • Loading branch information
LukeWeidenwalker authored Jul 14, 2023
1 parent cff6768 commit afca7c6
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import geopandas as gpd
import numpy as np
import xarray as xr
import xgboost as xgb
from xgboost.core import Booster

from openeo_processes_dask.process_implementations.cubes.experimental import (
load_vector_cube,
Expand All @@ -27,7 +27,9 @@ def fit_regr_random_forest(
predictors_vars: Optional[list[str]] = None,
target_var: str = None,
**kwargs,
) -> xgb.core.Booster:
) -> Booster:
import xgboost as xgb

params = {
"learning_rate": 1,
"max_depth": 5,
Expand Down Expand Up @@ -72,9 +74,11 @@ def fit_regr_random_forest(

def predict_random_forest(
data: RasterCube,
model: xgb.Booster,
model: Booster,
axis: int = -1,
) -> RasterCube:
import xgboost as xgb

n_features = len(model.feature_names)
if n_features != data.shape[axis]:
raise Exception(
Expand Down

0 comments on commit afca7c6

Please sign in to comment.