Documentation Index
Fetch the complete documentation index at: https://mintlify.com/LauraSilRu/exoplanet-profiler/llms.txt
Use this file to discover all available pages before exploring further.
03_preprocessing.ipynb transforms the raw TESS extract into a clean, scaled, and imputed matrix ready for PCA. It implements a strict completeness filter, applies log1p transforms to skewed variables, scales with RobustScaler, and imputes missing values with KNNImputer. The notebook works exclusively with the 12 candidate features agreed in notebooks 01 and 02 — no further variable selection is performed here.
Input Contract
Before running this notebook, the following conditions must be satisfied:
- File:
data/raw/exoplanets.csvmust exist - Identifier:
pl_namecolumn must be present with no nulls and no duplicates - Features: all 12
FEATURE_COLUMNSmust be present in the file - Auxiliary column:
disc_yearmust be present (used in completeness audit) - Domain constraints: all numeric variables must satisfy physical bounds —
pl_orbeccen∈ [0, 1];pl_orbper,pl_orbsmax,pl_rade,pl_bmasse,pl_insol, and stellar parameters must be positive where applicable
Completeness Filter
With several variables carrying high null rates —pl_insol missing in 57.58% of rows, pl_bmasse in 31.76%, pl_orbeccen in 31.32% — a row-level completeness gate is applied before imputation. Only planets with at least 8 of 12 features observed are retained. This ensures that KNNImputer never has to reconstruct more than four values per row, which would make the imputed values unreliable.
| Metric | Value |
|---|---|
| Rows in raw file | 910 |
| Rows retained | 731 (80.44%) |
| Rows excluded | 179 |
| Complete cases (0 nulls) | 249 |
| Cells imputed within retained set | ~9.99% |
preprocessing_row_audit.csv so that exclusions are fully auditable.
Transformations
Six of the 12 features are right-skewed positive variables.log1p (i.e., log(1 + x)) is applied to each of them to compress the right tail and reduce the influence of extreme values on downstream distance calculations.
Pipeline Order
The preprocessing steps are executed in a fixed order. Changing this order would produce different results.Log1p Transforms
Applied column-by-column to the six skewed features listed above. This step
must occur first, before any scaling, so that the scaler operates on the
already-compressed distributions.
RobustScaler
Centers each feature on its median and scales by its interquartile range
(IQR). Because it uses robust statistics rather than mean and standard
deviation, it is less sensitive to extreme values than
StandardScaler.Scaling must precede KNN imputation because KNNImputer computes Euclidean
distances between rows. Without scaling, variables with larger absolute ranges
would dominate the distance metric and distort neighbor selection.KNNImputer (n_neighbors=5, weights='distance')
Fills the remaining missing values using the five nearest observed neighbors,
weighted by inverse distance so that closer neighbors contribute more. Applied
after scaling so that all 12 features contribute equally to the distance
calculation used to find neighbors.
KNN vs Median Imputation
The choice of KNNImputer over simple median imputation was validated empirically. Using the 249 complete cases, 10% of values were randomly hidden (seed 42) and then reconstructed by each method. Error was measured in the transformed-and-scaled space.| Method | RMSE | MAE |
|---|---|---|
| Median | 0.7168 | 0.5651 |
| KNN (5 neighbors, distance weights) | 0.4026 | 0.2422 |
pl_insol in particular has very high missingness — but it provides a reproducible, quantitative justification for the choice.
Output Contract
The output file
data/processed/exoplanets_preprocessed.csv must satisfy all
of the following conditions before notebook 04 can proceed:- Exactly 731 rows
- Columns:
pl_name+ the 12FEATURE_COLUMNSin the agreed order - Zero nulls
- Zero infinities
- Zero duplicate identifiers
Output Artifacts
All files are written todata/processed/.
| File | Description |
|---|---|
exoplanets_preprocessed.csv | Clean 731 × 12 feature matrix — primary input for notebook 04 |
exoplanets_selected_raw.csv | Original (untransformed) values for the 731 retained rows |
preprocessing_row_audit.csv | Per-planet include/exclude decision with reason |
preprocessing_quality_summary.csv | Quality metrics summary (null rates, zero counts, shape) |
preprocessing_scaler_comparison.csv | Descriptive comparison of StandardScaler vs RobustScaler |
preprocessing_imputer_comparison.csv | Median vs KNN benchmark results (RMSE, MAE) |
preprocessing_pipeline.joblib | Fitted sklearn pipeline (log1p → RobustScaler → KNNImputer) |
preprocessing_metadata.json | Full pipeline contract: feature list, order, parameters, row counts |