Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Random Forest NPF Event Prediction

ARM Logo

Random Forest NPF Event Prediction

This notebook trains a Random Forest model to predict whether an NPF event happened on each day. Labels are mapped as b and e = event, n and u = non-event. The split is a random 9:1 train/checking split with stratification by event class and random_state=42 for reproducibility.

Load Merged Daily Data

Rows: 303
Date range: 2023-01-18 to 2023-12-29
Loading...

Prepare Features and Target

All numeric daily parameters except geometric_std variables are used as model inputs. Date and label columns are excluded from X, and feature names are shortened for plotting.

Feature count: 10
['UF mean', 'UF max', 'UF min', 'UF p25', 'UF p50', 'UF p75', 'GM mean', 'GM low25', 'GM low50', 'GM low75']

Dropped std variables:
['geometric_std_daily_mean_nm', 'geometric_std_smallest_25pct_daily_mean_nm', 'geometric_std_smallest_50pct_daily_mean_nm', 'geometric_std_smallest_75pct_daily_mean_nm']

Target counts:
is_event
non_event    195
event        108
Name: count, dtype: int64

Random Stratified 9:1 Split

Training rows: 272
Checking rows: 31
Random state: 42
Training date range: 2023-01-18 to 2023-12-27
Checking date range: 2023-01-19 to 2023-12-29

Training target counts:
is_event
non_event    175
event         97
Name: count, dtype: int64

Checking target counts:
is_event
non_event    20
event        11
Name: count, dtype: int64

Train Random Forest

Model trained.

Checking-Set Results

<Figure size 715x585 with 2 Axes>

ROC Curve

<Figure size 715x715 with 1 Axes>
ROC AUC: 0.805
<Figure size 832x624 with 2 Axes>

Checking-Set Predictions

Loading...

Feature Importance

Loading...
<Figure size 1040x650 with 1 Axes>

SHAP Summary Plot

<Figure size 390x780 with 2 Axes>