models
models
¶
Machine learning models for FPL prediction.
BaselineModel
¶
Bases: BaseModel
Baseline model using simple heuristics.
Methods: - Rolling average of points - Weighted recent form - Form-based prediction
Initialize baseline model.
| PARAMETER | DESCRIPTION |
|---|---|
method
|
Prediction method: 'rolling_mean', 'ewma', 'last_value'
TYPE:
|
window
|
Window size for rolling calculations
TYPE:
|
Source code in fplx/models/baseline.py
fit
¶
predict
¶
Predict next gameweek points for a player.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Player historical data
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
Predicted points |
Source code in fplx/models/baseline.py
batch_predict
¶
Predict for multiple players.
| PARAMETER | DESCRIPTION |
|---|---|
players_data
|
Dictionary mapping player ID to their data
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, float]
|
Dictionary of predictions |
Source code in fplx/models/baseline.py
EnsembleModel
¶
Ensemble combining multiple models with weighted averaging.
| PARAMETER | DESCRIPTION |
|---|---|
models
|
List of model instances
TYPE:
|
weights
|
Weights for each model (must sum to 1)
TYPE:
|
Source code in fplx/models/ensemble.py
predict
¶
Ensemble prediction for a single player.
| PARAMETER | DESCRIPTION |
|---|---|
player_data
|
Player historical data
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
Ensemble prediction |
Source code in fplx/models/ensemble.py
batch_predict
¶
Ensemble predictions for multiple players.
| PARAMETER | DESCRIPTION |
|---|---|
players_data
|
Dictionary mapping player ID to their data
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, float]
|
Dictionary of ensemble predictions |
Source code in fplx/models/ensemble.py
RegressionModel
¶
RegressionModel(
model_type: str = "ridge",
initial_train_size: int = 10,
test_size: int = 1,
step: int = 1,
**model_kwargs
)
Bases: BaseModel
Machine learning regression model for FPL predictions.
Adapted from the MLSP project's regressor patterns.
| PARAMETER | DESCRIPTION |
|---|---|
model_type
|
Type of model: 'ridge', 'xgboost', 'lightgbm'
TYPE:
|
initial_train_size
|
Size of initial training window
TYPE:
|
test_size
|
Forecast horizon
TYPE:
|
step
|
Rolling window step size
TYPE:
|
Source code in fplx/models/regression.py
fit
¶
predict
¶
Generate predictions.
Source code in fplx/models/regression.py
fit_predict
¶
Fit model and generate predictions using rolling CV.
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Target time series (points to predict)
TYPE:
|
X
|
Feature matrix
TYPE:
|
verbose
|
Print progress
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Series
|
Predictions aligned with test indices |
Source code in fplx/models/regression.py
predict_next
¶
Predict next value given features.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Feature matrix (single row for next gameweek)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
Predicted points |
Source code in fplx/models/regression.py
get_feature_importance
¶
Get feature importance (for tree-based models).
| PARAMETER | DESCRIPTION |
|---|---|
feature_names
|
Names of features
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
DataFrame
|
Feature importance scores |
Source code in fplx/models/regression.py
evaluate
¶
Evaluate model performance.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, float]
|
Dictionary of metrics |
Source code in fplx/models/regression.py
RollingCV
¶
Generates indices for rolling cross-validation splits.
This is adapted from the MLSP project for time-series validation.
| PARAMETER | DESCRIPTION |
|---|---|
initial_train_size
|
Size of the initial training set.
TYPE:
|
test_size
|
Size of the test set (forecast horizon).
TYPE:
|
step
|
Step size to move the training window forward.
TYPE:
|
Source code in fplx/models/rolling_cv.py
split
¶
Generate indices to split data into training and test sets.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Time series data.
TYPE:
|
| YIELDS | DESCRIPTION |
|---|---|
train_indices
|
The training set indices for that split.
TYPE::
|
test_indices
|
The testing set indices for that split.
TYPE::
|