Millised probleemid tekivad, lisades kuu numbri tunnusena?
sobes.tech AI
Vastus AI-lt
Adding the month number as a feature in a machine learning model can lead to several problems:
-
Cyclicity of the feature: The month number is a cyclic feature (after 12 comes 1). If represented as a numerical value from 1 to 12, the model might incorrectly interpret that 12 and 1 are very different, even though they are neighbors.
-
Incorrect perception of distances: The model might interpret the difference between months as linear, for example, considering month 12 and 1 as the most different, which does not reflect reality.
-
Problems with seasonality: If the model does not account for cyclicity, it might struggle to capture seasonal patterns.
To avoid these problems, cyclic features are usually transformed into two components using sine and cosine:
import numpy as np
month = 1 # example month
month_sin = np.sin(2 * np.pi * month / 12)
month_cos = np.cos(2 * np.pi * month / 12)
This way, the model sees the month as a point on a circle, which reflects cyclicity and improves learning quality.