An open API service indexing awesome lists of open source software.

https://github.com/sodascience/synthetic_youth_pilot

Synthetic data pilot for YOUth study questionnaires, using metasyn
https://github.com/sodascience/synthetic_youth_pilot

questionnaire-survey synthetic-data youth-data

Last synced: 8 months ago
JSON representation

Synthetic data pilot for YOUth study questionnaires, using metasyn

Awesome Lists containing this project

README

          

# YOUth pilot privacy-friendly synthetic data
![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=fff)
![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)

This repository implements a pilot for creating privacy-friendly questionnaire datasets from the YOUth cohort. It is built on [metasyn](https://github.com/sodascience/metasyn) with the [disclosure control plugin](https://github.com/sodascience/metasyn-disclosure-control).

## Installation

To install the dependencies of this project, follow the following steps:

1. We use [uv](https://docs.astral.sh/uv) to manage dependencies and environments. Install it first.
2. Clone this repository.
3. Instantiate the environment by running `uv sync` from this folder.

## Synthesizing data
1. Obtain the following datasets from the YOUth study and put them in the `raw_data` folder: `CECPAQ_2.csv`, `M_DEMOGRAFY_1.csv`, `P_DEMOGRAFY_1.csv`, `P_LIFSTYLE_1_MED_STOREY.csv`, `P_LIFSTYLE_1_MEDICATIONY.csv`, `P_LIFSTYLE_1.csv`, `Q_1.csv`
2. Obtain the following metadata files and put them in the `raw_data\metadata` folder: `YOUth_baby_en_kind-metadata.csv`, `YOUth_baby_en_kind-valuelabels.csv`.
3. Create the synthetic data by running `uv run synthesize.py`

Now, the folders `output/csv` and `output/gmf` should be populated with synthetic data and metadata, respectively:

```
πŸ“ synthetic_youth_pilot/
β”œβ”€β”€ πŸ“– README.md
β”œβ”€β”€ πŸ“„ test_analysis.py
β”œβ”€β”€ πŸ“„ synthesize.py
β”œβ”€β”€ pyproject.toml
β”œβ”€β”€ uv.lock
β”œβ”€β”€ πŸ“ raw_data/
β”‚ β”œβ”€β”€ πŸ“œ CECPAQ_2.csv
β”‚ β”œβ”€β”€ πŸ“œ M_DEMOGRAFY_1.csv
β”‚ β”œβ”€β”€ πŸ“œ P_DEMOGRAFY_1.csv
β”‚ β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1.csv
β”‚ β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1_MEDICATIONY.csv
β”‚ β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1_MED_STOREY.csv
β”‚ β”œβ”€β”€ πŸ“œ Q_1.csv
β”‚ └── πŸ“ metadata/
β”‚ β”œβ”€β”€ πŸ“œ YOUth_baby_en_kind-metadata.csv
β”‚ └── πŸ“œ YOUth_baby_en_kind-valuelabels.csv
└── πŸ“ output/
β”œβ”€β”€ πŸ“ csv/
β”‚ β”œβ”€β”€ πŸ“œ CECPAQ_2.csv
β”‚ β”œβ”€β”€ πŸ“œ M_DEMOGRAFY_1.csv
β”‚ β”œβ”€β”€ πŸ“œ P_DEMOGRAFY_1.csv
β”‚ β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1.csv
β”‚ β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1_MEDICATIONY.csv
β”‚ β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1_MED_STOREY.csv
β”‚ └── πŸ“œ Q_1.csv
└── πŸ“ gmf/
β”œβ”€β”€ πŸ“œ CECPAQ_2.json
β”œβ”€β”€ πŸ“œ M_DEMOGRAFY_1.json
β”œβ”€β”€ πŸ“œ P_DEMOGRAFY_1.json
β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1.json
β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1_MEDICATIONY.json
β”œβ”€β”€ πŸ“œ P_LIFSTYLE_1_MED_STOREY.json
└── πŸ“œ Q_1.json

5 directories, 28 files
πŸ“–README πŸ“œData πŸ“„Code πŸ“Folder
```
_(Made with [`scitree`](https://github.com/J535D165/scitree))_

## Test analysis

This repo includes a test analysis on both the real and synthetic data to display medication use by age bracket. You can find the analysis in the file [test_analysis.py](./test_analysis.py). To run this analysis, run `uv run test_analysis.py`. It will show something like the following:

```
Paracetamol use in real data:

Age: 10 - 19 | ____ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Age: 20 - 29 | ____ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Age: 30 - 39 | ____ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Age: 40 - 49 | ____ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Age: 50 - 59 | ____ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ

Paracetamol use in synthetic data:

Age: 10 - 19 | 0.81 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Age: 20 - 29 | 0.81 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Age: 30 - 39 | 0.78 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Age: 40 - 49 | 0.74 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Age: 50 - 59 | 0.81 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
```
_(numbers redacted & bars fuzzed in real data analysis for privacy)_

Three things are noteworthy here:
1. The analysis code is __exactly__ the same between the synthetic and real analyses
2. The ranges of the individual variables (age and paracetamol use) are similar
3. The relation between age and paracetamol use is removed from the synthetic data

## Contact

This is a project by the [ODISSEI Social Data Science team](https://odissei-soda.nl/). Do you have questions, suggestions, or remarks on the technical implementation? Create an issue in the issue tracker or feel free to contact [Erik-Jan van Kesteren](https://github.com/vankesteren).

SoDa logo