-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_regression_sample.py
More file actions
29 lines (24 loc) · 994 Bytes
/
Copy pathcreate_regression_sample.py
File metadata and controls
29 lines (24 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pandas as pd
import numpy as np
def create_regression_sample():
np.random.seed(42)
n = 200
data = {
'id': range(1001, 1001 + n),
'listing_date': pd.date_range(start='2023-01-01', periods=n, freq='D').strftime('%Y-%m-%d'),
'square_feet': np.random.randint(500, 5000, n),
'bedrooms': np.random.randint(1, 6, n),
'bathrooms': np.random.randint(1, 4, n),
'neighborhood': np.random.choice(['Downtown', 'Suburbs', 'Westside', 'Eastside'], n),
'price': []
}
# Simple pricing formula + noise
for i in range(n):
base = data['square_feet'][i] * 150 + data['bedrooms'][i] * 50000 + data['bathrooms'][i] * 30000
noise = np.random.normal(0, 15000)
data['price'].append(int(base + noise))
df = pd.DataFrame(data)
df.to_csv('Housing_Price_Sample.csv', index=False)
print("Created Housing_Price_Sample.csv")
if __name__ == "__main__":
create_regression_sample()