Dataset generation for mobile app testing

As part of MIT app inventor Hackathon, i and my teammate Viraj Marathe have developed a mobile app AllergyAlly. This AI-powered allergy companion app aims to revolutionise allergy management.

Medical history remains a cornerstone in allergy diagnosis, guiding healthcare providers in making informed decisions and providing appropriate care to patients. And this app documents each and every allergic incident and provides detailed report for the healthcare providers with the help of AI.

Existing solutions are not satisfactory and our mobile app Allergy ally acts as a companion to persons troubled by allergies.

For the rigorous testing of the mobile app we needed a dataset that we could use in the app so that the features of the app could be tested for accuracy.

We created a dataset

  1. Used python to generate patient allergy incident logs for every 2 days of a year
  2. The dataset has the symptoms, triggers, weather summary, mood levels and severity with a pattern to it and is not completely random.
  3. This dataset when entered in the app helps us visualise what an actual patients data over an year would look like

The python code that we used to create the dataset

import random
from datetime import datetime, timedelta

def generate_data_point(start_date, end_date):
# Generate a random date within the range
date_delta = random.randint(1, 3)
new_date = start_date + timedelta(days=date_delta)

# Location with change
base_latitude = 15.4739366
base_longitude = 73.813052
lat_offset = random.uniform(-0.02, 0.02)
lon_offset = random.uniform(-0.02, 0.02)

# Symptoms and Triggers (limited options)
all_symptoms = [
"Itchy red eyes", "Runny nose", "Itching of mouth and throat"
]
all_triggers = ["Pets"]

# Select a random number of symptoms (1 or 2)
num_symptoms = random.randint(1, 3)
selected_symptoms = random.sample(all_symptoms, num_symptoms)
symptom_severities = [str(random.randint(1, 5)) for _ in range(num_symptoms)]

# Select a random number of triggers (1 or 2)
num_triggers = 1
selected_triggers = random.sample(all_triggers, num_triggers)

# Weather data with variations
weather_options = [
{ # Mild day with scattered showers (moderate pollen, dust)
"grass_pollen": "Moderate",
"weed_pollen": "Moderate",
"tree_pollen": "Moderate",
"summary":
"Mild day with intermittent sunshine, and scattered clouds. Expect occasional light showers, with a chance of rainbow sightings. Air may carry a moderate amount of pollen and dust.",
"temperature": random.randint(65, 75),
"uvIndex":
str(random.randint(2, 3)) # Moderate UV for partly cloudy day
},
{ # Warm and humid with partly cloudy skies (moderate pollen, dust)
"grass_pollen": "Moderate",
"weed_pollen": "Moderate",
"tree_pollen": "Moderate",
"summary":
"Warm and humid, with a gentle breeze. Sky is partly cloudy, ideal for outdoor gatherings but watch out for sudden showers. Pollen levels are moderate, and dust may be stirred up by the breeze.",
"temperature": random.randint(75, 85),
"uvIndex":
str(random.randint(3,
4)) # Moderate to high UV for partly cloudy day
},
{ # Crisp autumn morning (low pollen, some dust)
"grass_pollen": "Low",
"weed_pollen": "Low",
"tree_pollen": "Low",
"summary":
"Crisp autumn morning, clear skies. Leaves rustle in the breeze, hinting at the changing season, perfect for a brisk walk. Pollen levels are low, but some dust may be present in the air.",
"temperature": random.randint(45, 60),
"uvIndex": str(random.randint(1, 2)) # Low UV for clear day
},
{ # Winter wonderland (minimal pollen, indoor dust)
"grass_pollen": "Low",
"weed_pollen": "Low",
"tree_pollen": "Low",
"summary":
"Freezing temperatures, heavy snowfall. Winter wonderland scenery, but travel may be difficult due to icy roads and low visibility. Pollen levels are minimal, but indoor dust may be stirred up by heating systems.",
"temperature": random.randint(10, 30),
"uvIndex": str(1) # Minimal UV for winter day
},
{ # Sweltering heatwave (low pollen, dust)
"grass_pollen": "Low",
"weed_pollen": "Low",
"tree_pollen": "Low",
"summary":
"Sweltering heatwave, no relief in sight. Sun beats down relentlessly, stay hydrated and seek shade if outdoors. Pollen levels are low, but dust may be kicked up by the heat.",
"temperature": random.randint(90, 105),
"uvIndex": str(4) # High UV for clear day
},
{ # Foggy and misty (minimal pollen, dust trapped)
"grass_pollen": "Low",
"weed_pollen": "Low",
"tree_pollen": "Low",
"summary":
"Foggy and misty, visibility low. Drive cautiously and keep headlights on, as the fog envelops the landscape in a mysterious veil. Pollen levels are minimal, but dust may be trapped in the moisture.",
"temperature": random.randint(45, 60),
"uvIndex": str(1) # Low UV for foggy conditions
},
{ # Chilly and damp (low pollen, indoor dust)
"grass_pollen": "Low",
"weed_pollen": "Low",
"tree_pollen": "Low",
"summary":
"Chilly and damp, persistent drizzle. Gray skies overhead, a day best spent indoors with a hot cup of cocoa. Pollen levels are low, but indoor dust may be more noticeable due to closed windows.",
"temperature": random.randint(50, 65),
"uvIndex": str(1) # Low UV for overcast day
},
{ # Blustery winds, dust storms possible (low pollen, dust)
"grass_pollen": "Low",
"weed_pollen": "Low",
"tree_pollen": "Low",
"summary":
"Blustery winds, dust storms possible. Hold onto your hats as gusts whip through the air, reducing visibility and kicking up dirt. Pollen levels are low, but dust storms may worsen air quality.",
"temperature": random.randint(60, 75),
"uvIndex":
str(2
) # Moderate UV for partly cloudy day (wind may break up clouds)
},
{ # Clear night with a chance of northern lights (minimal pollen, indoor dust)
"grass_pollen": "Low",
"weed_pollen": "Low",
"tree_pollen": "Low",
"summary":
"Clear night with a chance of northern lights. Bundle up and head outside for a chance to witness the mesmerizing dance of the auroras. Pollen levels are minimal, but indoor dust may settle overnight.",
"temperature": random.randint(20, 40),
"uvIndex": str(1) # Minimal UV for night
},
{ # Hazy and smoggy (low pollen except tree, dust/pollution)
"grass_pollen": "Low",
"weed_pollen": "Low",
"tree_pollen": "Moderate",
"summary":
"Hazy and smoggy, poor air quality. Pollution hangs thick in the air, advisable to limit outdoor activities, especially for sensitive individuals. Pollen levels are low, except for tree pollen which may be moderate due to late bloomers.",
"temperature": random.randint(70, 80),
"uvIndex": str(2) # Moderate UV for hazy conditions
}
]

weather = random.choice(weather_options)

# Calculate average symptom severity (numeric)
average_severity = sum(int(x) for x in symptom_severities) / num_symptoms

# Mood based on severity (higher severity = lower mood)
mood_offset = max(0, (average_severity - 3) /
2) # Clamped to prevent negative mood
mood = random.uniform(0, 5 - mood_offset)

data = {
"DateAndTime": {
"Date": new_date.strftime('%d/%m/%Y'),
"DayOfMonth": new_date.day,
"Hour": random.randint(0, 23),
"Minute": random.randint(0, 59),
"Month": new_date.month,
"Year": new_date.year
},
"Location": {
"Altitude": -45.19065654260672,
"Latitude": base_latitude + lat_offset,
"Longitude": base_longitude + lon_offset
},
"Mood": float(average_severity),
"SymptomData": {
"AverageSymptomSeverity":
sum(int(x) for x in symptom_severities) / num_symptoms,
"SymptomCount": num_symptoms,
"SymptomNames": selected_symptoms,
"SymptomSeverities": symptom_severities,
"Symptoms": dict(zip(selected_symptoms, symptom_severities)),
"TriggerCount": num_triggers,
"Triggers": selected_triggers
},
"Weather":
weather,
"Image":
"iVBORw0KGgoAAAANSUhEUgAAAMcAAACUCAMAAAAQwc2tAAAAA1BMVEXPOT1rZS0MAAAANElEQVR4nO3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADg1wBzoAABVhrrmQAAAABJRU5ErkJggg=="
}
return data


start_date = datetime(2023, 1, 1)
end_date = datetime(2023, 12, 31)

data_list = []
current_date = start_date
while current_date <= end_date:
data_list.append(generate_data_point(current_date, end_date))
current_date += timedelta(
days=2) # Move to the next data point (2 days later)

print(data_list) # Example: Print the generated data

Comments

Popular posts from this blog

My Learnings from FTC

Brahma of Goa

Press mention for the International success at MAKEX 2022