-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_synthetic.py
More file actions
23 lines (22 loc) · 817 Bytes
/
make_synthetic.py
File metadata and controls
23 lines (22 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# make_synthetic.py
import csv, random
streams = ["science","arts","commerce","vocational"]
rows = []
for i in range(800):
stream = random.choices(streams, weights=[4,3,3,2])[0]
answers = []
for q in range(10):
if stream=="science":
answers.append(random.choices([1,2,3,4], weights=[5,2,1,1])[0])
elif stream=="arts":
answers.append(random.choices([1,2,3,4], weights=[1,1,5,2])[0])
elif stream=="commerce":
answers.append(random.choices([1,2,3,4], weights=[1,2,1,5])[0])
else:
answers.append(random.randint(1,4))
rows.append(answers + [stream])
with open("dataset.csv","w",newline="") as f:
w = csv.writer(f)
w.writerow([f"Q{i+1}" for i in range(10)]+["Stream"])
w.writerows(rows)
print("Wrote dataset.csv")