Quiz 2
Registry Synced

Learning Objectives

248 words
1 min read

Learning Objectives

  • Clean and preprocess data
  • Create meaningful features
  • Prepare data for modeling
python
from sklearn.preprocessing import StandardScaler, LabelEncoder
from sklearn.model_selection import train_test_split
import pandas as pd
import numpy as np
# Handle missing values
df['numeric_col'] = df['numeric_col'].fillna(df['numeric_col'].median())
df['categorical_col'] = df['categorical_col'].fillna('Unknown')
# Encode categorical variables
le = LabelEncoder()
df['encoded'] = le.fit_transform(df['category'])
# Or one-hot encode
df = pd.get_dummies(df, columns=['category'])
# Feature scaling
scaler = StandardScaler()
df'feature1', 'feature2' = scaler.fit_transform(df'feature1', 'feature2')
# Feature engineering
df['feature_product'] = df['feature1'] * df['feature2']
df['feature_ratio'] = df['feature1'] / (df['feature2'] + 1e-6)
# Train/test split
X = df.drop('target', axis=1)
y = df['target']
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42, stratify=y
)
Q1: Why scale features?
Features with larger scales dominate algorithms using distance/distance-based (KNN, SVM, PCA, gradient descent). Tree-based models are scale-invariant. Q2: When to use Label Encoding vs One-Hot Encoding?
Label: ordinal categories (small, medium, large). One-hot: nominal categories (red, blue, green) - prevents implying order. Q3: What are interaction features?
Product or combination of existing features. Captures non-linear relationships. Example: price * quantity = revenue. Q4: How to handle date/time features?
Extract: year, month, day, dayofweek, quarter, is_weekend, hour, elapsed_time since reference date. Q5: What is feature selection?
Identify most predictive features. Methods: correlation, mutual information, feature importance from tree models, L1 regularization, Recursive Feature Elimination (RFE). Join Discord PreviousMilestone 2: Exploratory Data Analysis (EDA)NextMilestone 4: Model Training & Evaluation
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.