-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_generator.py
More file actions
64 lines (54 loc) · 1.75 KB
/
Copy pathdata_generator.py
File metadata and controls
64 lines (54 loc) · 1.75 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import csv
import random
# Number of data rows
num_rows = 2000
# Open CSV file
with open("dataset.csv", mode="w", newline="") as file:
writer = csv.writer(file)
# Header (column names)
writer.writerow([
"age", "gender", "bp", "heart_rate", "spo2",
"bmi", "temperature", "smoker", "activity",
"duration", "symptom_score", "risk"
])
for _ in range(num_rows):
# Generate random data
age = random.randint(18, 80)
gender = random.choice(["M", "F"])
bp = random.randint(90, 180)
heart_rate = random.randint(60, 120)
spo2 = random.randint(85, 100)
bmi = random.randint(18, 35)
temperature = random.randint(97, 103)
smoker = random.choice([0, 1])
activity = random.choice(["low", "medium", "high"])
duration = random.randint(1, 10)
symptom_score = random.randint(1, 10)
# Risk calculation logic (simulating AI decision logic)
risk_score = 0
if bp > 140:
risk_score += 2
if heart_rate > 100:
risk_score += 2
if spo2 < 92:
risk_score += 3
if temperature > 100:
risk_score += 2
if smoker == 1:
risk_score += 1
if symptom_score > 6:
risk_score += 2
# Final label
if risk_score >= 7:
risk = "High"
elif risk_score >= 4:
risk = "Moderate"
else:
risk = "Low"
# Write row
writer.writerow([
age, gender, bp, heart_rate, spo2,
bmi, temperature, smoker, activity,
duration, symptom_score, risk
])
print("Dataset created successfully!")