Feature engineering
Not met yet
Feature engineering is rewriting readings so a model can use what they mean. A compass direction wraps round, so 350 and 10 degrees look far apart as numbers: write the wind as an arrow, speed * sin(angle) east and speed * cos(angle) north, with the angle in radians. A clock time can become hours from the moment that matters, like dawn. A reading's change, days["pressure"].diff(), can say more than the reading itself. A model can only find a pattern that's there in its columns. In a forecast, build features only from what's known by then: never from later rows.
Try it
main.pyimport numpy as np
import pandas as pd
days = pd.DataFrame({"wind_speed": [15, 15], "wind_dir": [350, 10], "pressure": [1012, 1005]})
angle = np.radians(days["wind_dir"])
days["wind_east"] = days["wind_speed"] * np.sin(angle)
days["wind_north"] = days["wind_speed"] * np.cos(angle)
days["pressure_change"] = days["pressure"].diff()
print(days.round(1))
Output
Press Run and what your program prints shows up here.
Easy to get wrong
- Thinks a model knows that compass directions wrap round, so 350 and 10 degrees look close to it.
- Thinks rewriting a reading, like a direction as east and north parts, can't help a model, because the information is the same.
- Thinks a feature may be built from later rows, like tomorrow's pressure, in a forecast.
- Thinks adding any extra column always makes a model better.