Memuat
Memuat
Random Forest with Lag Features for Chemistry and Materials
0 views
Forecast residual dye concentration in dye adsorption by activated carbon with a lag-feature Random Forest and compare it with a simple baseline. 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 residual dye concentration in dye adsorption by activated carbon with a lag-feature Random Forest and compare it with a simple baseline.
| Role | Variable | Unit |
|---|---|---|
| Main | residual dye concentration | mg/L |
| Supporting 1 | solution pH | - |
| Supporting 2 | contact time | menit |
The lag-feature random forest model forecasts residual dye concentration 12 periods ahead with RMSE 8.481 and MAPE 8.82%. 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
solution_ph = np.arange(n)
residual_dye_concentration = 100 + 0.2 * solution_ph + 12 * np.sin(2 * np.pi * solution_ph / 12) + rng.normal(0, 2, n)
df = pd.DataFrame({"y": residual_dye_concentration})
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$88
excl. 11% VAT
Duration: 13 working days
Output: Code + analysis + interpretation notes
Includes all of Package 1, plus
Package 3
US$194
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 Chemistry and Materials. 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$88 and Package 3 (full guidance) US$194, 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