Memuat
Memuat
Random Forest with Lag Features for Civil Engineering and Transportation
0 views
Forecast channel water level with Random Forest with Lag Features using previous-hour rainfall and tide level as supporting variables. Random forest with lag features uses past values of the series as predictors, turning forecasting into tabular regression. It suits series with nonlinear patterns or many extra explanatory variables.

Forecast channel water level with Random Forest with Lag Features using previous-hour rainfall and tide level as supporting variables.
| Role | Variable | Unit |
|---|---|---|
| Main | Channel water level | cm |
| Supporting 1 | Previous-hour rainfall | mm |
| Supporting 2 | Tide level | m |
The lag-feature random forest model forecasts Channel water level 12 periods ahead with RMSE 4.111 and MAPE 1.65%. The most important lag is t-12.
Computed from illustrative synthetic data, not from a real study.
Random forest with lag features uses past values of the series as predictors, turning forecasting into tabular regression. It suits series with nonlinear patterns or many extra explanatory variables.
Report MAE and RMSE against a naive baseline and the most important lags. Explain that this is one-step-ahead evaluation using actual lags.
A short starting script with this project's variable names. The delivered version is adapted to your data and fully commented.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestRegressor
rng = np.random.default_rng(14)
n = 240
previous_hour_rainfall = np.arange(n)
channel_water_level = 100 + 0.2 * previous_hour_rainfall + 12 * np.sin(2 * np.pi * previous_hour_rainfall / 12) + rng.normal(0, 2, n)
df = pd.DataFrame({"y": channel_water_level})
for k in (1, 2, 3, 12):
df[f"lag{k}"] = df["y"].shift(k)
df = df.dropna().reset_index(drop=True)
split = len(df) - 24
X = df.drop(columns="y").values
y = df["y"].values
rf = RandomForestRegressor(n_estimators=300, random_state=14)
rf.fit(X[:split], y[:split])
pred = rf.predict(X[split:])
naive = df["lag1"].values[split:]
print("RF MAE:", round(np.abs(y[split:] - pred).mean(), 3),
"RMSE:", round(np.sqrt(((y[split:] - pred) ** 2).mean()), 3))
print("Naive MAE:", round(np.abs(y[split:] - naive).mean(), 3))
print(dict(zip(df.columns[1:], rf.feature_importances_.round(3))))
plt.plot(y[split:], label="Actual")
plt.plot(pred, label="RF")
plt.plot(naive, "--", label="Naive")
plt.legend()
plt.show()Choose how much help you need. Each higher package includes everything in the lower ones. Prices exclude 11% VAT.
Package 1
US$31
excl. 11% VAT
Duration: 7 working days
Output: Python files + result figures
Deliverables
Package 2 · most chosen
US$91
excl. 11% VAT
Duration: 13 working days
Output: Code + analysis + interpretation notes
Includes all of Package 1, plus
Package 3
US$200
excl. 11% VAT
Duration: 18-21 working days
Output: Code + analysis + guidance until ready to present
Includes all of Packages 1 & 2, plus
Yes. Random Forest with Lag Features is commonly used at this level in Civil Engineering and Transportation. We adapt the analysis to your research question, your own data and your supervisor's requirements.
No. The sheet is computed from illustrative synthetic data so you can see the kind of output Python gives. For your order we run the same method on your own data.
That is the point of the packages. Every script is commented, and Package 3 includes two coaching sessions plus practice questions so you can explain the method and the results at your seminar and defence.
Each project has three packages: Package 1 (code and explanation) US$31, Package 2 (your data analysis and interpretation) US$91 and Package 3 (full guidance) US$200, excluding 11% VAT. Larger datasets, extra methods or tight deadlines adjust the quote after a short consultation.
The result sheet uses illustrative synthetic data. Python is a trademark of the Python Software Foundation.
Back to Python portfolio