Skip to content

Commit 4c9c682

Browse files
authored
Create data_generator.py
1 parent 4e259a0 commit 4c9c682

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

data_generator.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import numpy as np
2+
import pandas as pd
3+
4+
def generate_multivariate_timeseries(n_samples=1500, n_features=5):
5+
time = np.arange(n_samples)
6+
7+
data = {}
8+
for i in range(n_features):
9+
data[f"feature_{i+1}"] = (
10+
np.sin(0.02 * time + i) +
11+
np.cos(0.01 * time) +
12+
np.random.normal(0, 0.1, n_samples)
13+
)
14+
15+
df = pd.DataFrame(data)
16+
df["target"] = (
17+
df["feature_1"] * 0.4 +
18+
df["feature_2"] * 0.3 +
19+
df["feature_3"] * 0.2 +
20+
np.random.normal(0, 0.05, n_samples)
21+
)
22+
return df
23+
24+
if __name__ == "__main__":
25+
df = generate_multivariate_timeseries()
26+
df.to_csv("data.csv", index=False)
27+
print("Data generated and saved as data.csv")

0 commit comments

Comments
 (0)