Predict module¶
-
class
pyro_risks.pipeline.predict.
PyroRisk
(model: Optional[str] = 'RF')[source]¶ Bases:
object
Pyronear Wildfire Risk Forecaster
Load a trained pipeline from pyrorisks remote model registry, download features from publicly available data sources (CDS API). Forecast the local (NUTS 3 level) daily wildfire risks (forest fire danger) in a Given Country (France).
- Parameters
model – Can be ‘RF’ for random forest or ‘XGBOOST’ for xgboost. Defaults to ‘RF’.
- Raises
ValueError – Model can be only of type RF or XGBOOST
-
expose_predictions
(day: str, country: Optional[str] = 'France', dir_path: Optional[str] = None, dir_destination: Optional[str] = None) → dict[source]¶ Serves a prediction for the specified day.
- Parameters
day – Date of interest (‘%Y-%m-%d’) for example ‘2020-05-05’.
country – Country of interest. Defaults to ‘France’.
dir_path – Location of the predictions to download, relative to the root of the dvc project.
to None. (Defaults) –
- Returns
keys are departements, values dictionaries whose keys are score and explainability and values probability predictions for label 1 (fire) and feature contributions to predictions respectively.
- Return type
dict[dict]
-
static
get_inputs
(day: str, country: Optional[str] = 'France', dir_destination: Optional[str] = None) → None[source]¶ Download datasets and build features for forecasting daily wildfire risks on a given date.
The get_inputs method downloads datsets from publicly available data sources (CDS API) and build features for forecasting wildfire risks on a given date. The downloaded inputs are persited in the destination csv file.
- Parameters
day – Date of interest (‘%Y-%m-%d’) for example ‘2020-05-05’.
country – Country of interest. Defaults to ‘France’.
destination – Location where the daily inputs are persisted.
to None (Defaults) –
-
get_pipeline
(path: Optional[str] = None, destination: Optional[str] = None) → None[source]¶ Download trained pipeline from remote model registry.
The get_pipeline method downloads the selected trained pipeline from the pyrorisks remote model registry. The downloaded pipeline is persited in the destination joblib file.
- Parameters
path – Location and file name of the pipeline to download, relative to the root of the
project. Defaults to None (dvc) –
destination – Location where the pipeline is downloaded. Defaults to None (self.model_path).
-
get_predictions
(day: str, country: Optional[str] = 'France', dir_path: Optional[str] = None, dir_destination: Optional[str] = None) → None[source]¶ Download predictions for the day of interest from the remote prediction registry.
The get_predictions method downloads the forecasted local wildfire risks at a given day in a given country (France). The downloaded predictions are persited in the destination joblib file.
- Parameters
day – Date of interest (‘%Y-%m-%d’) for example ‘2020-05-05’.
country – Country of interest. Defaults to ‘France’.
dir_path – Location of the predictions to download, relative to the root of the dvc project.
to None. (Defaults) –
dir_destination – Location where the daily predictions are persisted. Defaults to None.
-
load_inputs
(day: str, country: Optional[str] = 'France', usecols: Optional[List[str]] = None, dir_path: Optional[str] = None) → None[source]¶ Load inputs from local path.
- Parameters
day – Date of interest (‘%Y-%m-%d’) for example ‘2020-05-05’.
country – Country of interest. Defaults to ‘France’.
dir_path – Location where the daily inputs have been persisted. Defaults to None
(cfg.PREDICTIONS_REGISTRY). –
-
load_pipeline
(path: Optional[str] = None) → None[source]¶ Load trained pipeline from local path.
- Parameters
path – Location where the pipeline has been downloaded. Defaults to None (self.model_path).
-
predict
(day: str, country: Optional[str] = 'France', zone_column: Optional[str] = 'departement', dir_destination: Optional[str] = None) → None[source]¶ Predict local daily wildfire risks in a given country.
Forecast the local (NUTS 3 level) daily wildfire risks (forest fire danger) in a given country (France). Note that predictions on fwi and era5land data queried from CDS API will return 93 departments instead of 96 for France.
- Parameters
day – Date of interest (‘%Y-%m-%d’) for example ‘2020-05-05’.
country – Country of interest. Defaults to ‘France’.
dir_destination – Location where the daily inputs are persisted.
to None (Defaults) –