Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move xgb import to occur at runtime #135

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 predict_random_forest(
data: RasterCube,
model: xgb.Booster,
model: Booster,
axis: int = -1,
) -> RasterCube:
import xgboost as xgb

Check warning on line 80 in openeo_processes_dask/process_implementations/ml/random_forest.py

View check run for this annotation

Codecov / codecov/patch

openeo_processes_dask/process_implementations/ml/random_forest.py#L80

Added line #L80 was not covered by tests

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