mirror of
https://github.com/Dasemu/skipredictor.git
synced 2026-11-26 15:26:15 +00:00
fix(ml): resolve km_open under-prediction and remove Rule 3
- Removed data leakage features (lifts_open, snow_depth) from ML training. - Added station_id as an encoded categorical feature to enable station-awareness. - Removed Rule 3 (warm rain reduction) from the rules engine to avoid double-penalization. - Retrained all models with the corrected feature set.
This commit is contained in:
1 parent
6aa37f88e7
commit
b5b62e582e
3 files changed
+37
-39
No files matched your search
@@ -220,6 +220,7 @@ class ModelTrainer:
|
||||
non_feature_cols = target_cols | {
|
||||
"date",
|
||||
"station",
|
||||
# station_id is handled separately as a categorical feature
|
||||
"station_id",
|
||||
# open_status is an alias for station_open (target); exclude it
|
||||
"open_status",
|
||||
@@ -227,6 +228,9 @@ class ModelTrainer:
|
||||
"snow_quality",
|
||||
# season is a string label, not a numeric feature
|
||||
"season",
|
||||
# Data leakage: these are targets/status variables not in forecasts
|
||||
"lifts_open",
|
||||
"snow_depth",
|
||||
}
|
||||
# Also exclude any remaining object/string columns to prevent sklearn errors
|
||||
string_cols = set(
|
||||
@@ -237,6 +241,9 @@ class ModelTrainer:
|
||||
self._feature_columns = [
|
||||
col for col in self._df.columns if col not in non_feature_cols
|
||||
]
|
||||
# station_id will be added back as an encoded numeric feature
|
||||
self._feature_columns.append("station_id")
|
||||
|
||||
logger.info(
|
||||
"Dataset loaded: %d rows, %d features",
|
||||
len(self._df),
|
||||
@@ -256,6 +263,13 @@ class ModelTrainer:
|
||||
)
|
||||
|
||||
X = df[self._feature_columns].copy()
|
||||
|
||||
# Encode station_id
|
||||
station_le = LabelEncoder()
|
||||
X["station_id"] = station_le.fit_transform(X["station_id"].astype(str))
|
||||
joblib.dump(station_le, self.models_dir / "station_id_label_encoder.joblib")
|
||||
logger.debug("Encoded station_id using classes: %s", list(station_le.classes_))
|
||||
|
||||
X = X.fillna(X.median(numeric_only=True))
|
||||
|
||||
# Calculate sample weights based on date recency
|
||||
|
||||
Reference in new issue
Block a user