File size: 2,399 Bytes
ef987bb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Titanic data cleaning and survival report
Create a root `solve.py` that reads the current `titanic.csv`, creates `titanic_clean.csv` and `report.html` in the same directory, and runs offline. Compute results from the input each time; do not hard-code the bundled records or outputs.
## Cleaned data
- Resolve missing age and deck values by reasonable imputation or dropping rows missing one of these fields. Keep all complete rows and do not alter observed ages, decks or other original fields. Filled ages should be finite and within the observed age range. Keep a nonempty dataset with no missing age or deck.
- Keep the original category labels for `embarked` and `class` and add `embarked_code` and `class_code` as nonnegative integers. Within each field, use one distinct, consistent code per category. Pandas is optional; CSV does not carry category dtypes.
- Add boolean `is_alone`, true exactly when `sibsp + parch == 0`.
## Report
Summarize cleaning and the final row count. Compute survivors, total and survival rate separately for each sex category and each class category from the **final cleaned CSV**. In `<table id="survival-rates">`, display the category, counts and rate for each group. For each data row provide `data-group` (`sex` or `class`), `data-category` (original label), `data-survived`, `data-total` and `data-rate` (fraction from 0 to 1).
Include a visible `<svg id="survival-chart">` bar chart. Use exactly one `<rect>` per category with numeric `width` and `height` and matching `data-group`, `data-category` and `data-rate`; reserve rectangles in this SVG for the bars. Scale the bar width or height proportionally to the rate on a shared zero-origin scale. Display rates with sufficient precision, such as three fractional decimals or one decimal place for percentages. Print readable cleaning and report progress, for example, `[1/3] Cleaning age and deck` or percentage progress with named stages.
## Acceptance Checklist
- Running the script on the current or changed input preserves complete records and unchanged source fields, resolves missing age/deck, and computes reproducible codes and `is_alone`.
- The visible table and chart reflect the cleaned output, for every sex and class category. Visible counts and rates agree with metadata and bar lengths.
- Both outputs are regenerated and the script visibly reports cleaning and reporting progress.
|