File size: 3,039 Bytes
ef987bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Boston housing and Titanic analysis

Run the analysis as `python3 solve.py` from the project root using `BostonHousing.txt` (whitespace-delimited with a header) and `titanic.csv`. Work offline and do not change the inputs. Recompute `boston_clean.csv`, `titanic_clean.csv`, and `report.html` whenever inputs change. Print clear progress for the processing stages.

## Boston housing

- Calculate Q1 and Q3 of `medv` by linear interpolation at sorted positions `(n-1) × q`. Keep records within the inclusive fences Q1 − 1.5×IQR and Q3 + 1.5×IQR, preserving the original fields. Add `rm_rounded` by rounding positive room counts to the nearest integer, with half values rounded up.
- On the raw data compute Pearson r between each other numeric feature and `medv`; rank the top three by absolute correlation, using the feature name to break ties. On the cleaned data calculate mean `medv` for each `rm_rounded` group.
- Plot every cleaned observation with `rm` on x, `medv` on y, and the fitted least-squares line. Use independent SVG marks or Canvas 2D circles, ellipses or rectangles at most 20 px across. Use a plot spanning at least 50 px in each direction, with no decorative marks in the data series. Both linear axes increase right/up and have at least two numeric ticks consistent with the plotted coordinates (x below, y to the left).

## Titanic

Resolve missing `age` and `deck` by imputation or dropping only affected rows. Keep all complete rows, preserve other fields and observed values, and use finite imputed ages within the observed range. Treat `embarked` and `class` as categorical; pandas is optional and CSV need not encode dtypes. Add `is_alone`, true exactly when `sibsp + parch == 0`.

Use the cleaned rows to compute survival rates for each sex-by-class combination. Draw one bar for each combination, labeled below with both sex and class, including groups with zero rate. Heights share a zero baseline and a linear scale; show 0 and 1 (or 0% and 100%) on the left axis.

## Report and acceptance

Use visible, legible HTML tables with a single header row and no merged data cells. Labels may be equivalent English or Chinese; table IDs, row order and styling are unrestricted. Show measurements to at least two decimal places (counts exact); percentages are acceptable for survival rates. Keep tables and graphics fully visible.

## Acceptance Checklist

- Boston CSV contains all and only in-fence records with unchanged data and correct half-up room groups. The report shows the five `Metric / Value` entries Q1, Q3, lower, upper and outliers, the top three `Feature / Pearson r`, and `rm_rounded / Mean medv` for all groups.
- Titanic CSV retains complete records, handles missing values and computes `is_alone`. The visible `Sex / Class / Survival rate` table follows the cleaned data.
- The Boston scatter and trend line and the Titanic bars, ticks and group labels represent the computed results. Processing progress is printed, and regenerating results from changed data does not modify the inputs.