train/test में विभाजित करने से पहले features को scale करना।
→पहले विभाजित करें, फिर केवल train पर transformers फिट करें और test पर लागू करें (`transform`)। चरणों को एक scikit-learn Pipeline में wrap करें।
क्यों: पूर्ण dataset पर fitting करने से test statistics training में लीक होते हैं और evaluation scores को बढ़ाते हैं।
एक numeric column में 8% missing values हैं।
→`SimpleImputer` के माध्यम से median (skew के प्रति robust) से impute करें; एक missing-indicator flag पर विचार करें।
क्यों: Median outliers का विरोध करती है; एक indicator signal को संरक्षित करता है जब missingness स्वयं जानकारीपूर्ण होती है।
एक categorical column में gaps हैं।
→mode या एक स्पष्ट "Unknown" / "Missing" category से impute करें।
क्यों: एक स्पष्ट category, missingness pattern को उपयोग करने योग्य signal के रूप में रखती है बजाय पंक्तियों को discard करने के।
Low-cardinality nominal feature (जैसे 5 मानों वाला region)।
→one-hot encoding (`OneHotEncoder`) लागू करें; यदि मॉडल को कोई collinearity की आवश्यकता नहीं है तो एक column छोड़ दें।
क्यों: One-hot, nominal categories पर एक गलत क्रम लगाने से बचता है; एक स्तर को छोड़ने से dummy trap को रोका जा सकता है।
Feature में एक प्राकृतिक क्रम है (low / medium / high)।
→rank को संरक्षित करने वाले ordinal encoding का उपयोग करें।
क्यों: One-hot, ordering को discard कर देगा; rank-aware encoding मॉडल को इसका लाभ उठाने देता है।
हजारों स्तरों वाला categorical (जैसे ZIP code)।
→one-hot के बजाय target/frequency encoding या grouping का उपयोग करें।
क्यों: One-hot dimensionality को explode करता है; target encoding compact होता है लेकिन leakage से बचने के लिए इसे CV के अंदर फिट किया जाना चाहिए।
distance-based मॉडल से पहले features बहुत अलग scales में फैले हुए हैं।
→लगभग Gaussian features के लिए StandardScaler (zero mean, unit variance); [0,1] को बांधने के लिए MinMaxScaler।
क्यों: KNN, SVM, PCA, और gradient descent scale-sensitive होते हैं; tree models नहीं होते हैं।
एक right-skewed positive feature एक linear मॉडल को नुकसान पहुँचाता है।
→पूंछ को संपीड़ित करने के लिए एक log या Box-Cox/Yeo-Johnson power transform लागू करें।
क्यों: Skew को कम करने से variance स्थिर होता है और linear और distance-based models के लिए संबंधों को linearises करता है।
एक linear मॉडल में एक गैर-रेखीय आयु प्रभाव को पकड़ना चाहते हैं।
→continuous feature को ranges (equal-width या quantile) में bin करें और categorical के रूप में मानें।
क्यों: Binning, linear models को step changes को पकड़ने देता है, कुछ जानकारी के नुकसान की कीमत पर।
वास्तविक extreme values मॉडल training को अस्थिर करते हैं।
→एक percentile पर cap/winsorise करें या एक robust scaler का उपयोग करें; केवल पुष्टि की गई त्रुटियों को हटाएँ।
क्यों: Capping, extremes के leverage को सीमित करता है जबकि records को रखता है; विलोपन वास्तविक rare-event signal को खो देता है।
Positive class training rows का केवल 3% है।
→Resample — SMOTE/oversample minority या undersample majority — केवल training fold पर fitting; या class weights सेट करें।
क्यों: Test set को संतुलित करने से गलत रीडिंग मिलेगी; resampling training pipeline के अंदर होता है।
Raw timestamps और amounts under-perform करते हैं।
→Features engineer करें — day-of-week, time-since-last-event, ratios, प्रति ग्राहक aggregates।
क्यों: Domain-informed derived features अक्सर algorithm को बदलने से अधिक लाभ जोड़ते हैं।
सैकड़ों features, कई redundant या noisy।
→filter (correlation/mutual information), wrapper (RFE), या embedded (L1/tree importances) methods के माध्यम से select करें।
क्यों: कम, प्रासंगिक features overfitting, training cost को कम करते हैं, और interpretability में सुधार करते हैं।
कई correlated numeric features training को धीमा करते हैं और overfit करते हैं।
→PCA को शीर्ष components पर project करने के लिए लागू करें जो अधिकांश variance को कैप्चर करते हैं; पहले scale करें।
क्यों: PCA multicollinearity को हटाता है और dimensionality को संपीड़ित करता है, कुछ interpretability को stability के लिए trade करता है।
Multiple preprocessing steps को train और serving में समान रूप से लागू होना चाहिए।
→इंप्यूटर्स, एनकोडर्स, और स्कैलर्स को एक `Pipeline` / `ColumnTransformer` में चेन करें जिसे केवल training डेटा पर फिट किया गया हो।
क्यों: एक एकल fitted pipeline लगातार transforms की गारंटी देता है और folds के पार leakage को रोकता है।
संदर्भ↗
एक raw date column कम predictive value जोड़ता है।
→साल, महीना, सप्ताह का दिन, is-weekend, और cyclical sin/cos encodings में decompose करें।
क्यों: Models raw timestamp से calendar semantics को नहीं पढ़ सकते हैं; स्पष्ट भाग seasonality को उजागर करते हैं।