Build a model using only pandas/numpy
Build a Machine Learning Model from Scratch using Pandas and NumPy
You are provided with a tabular dataset as a pandas DataFrame df. This DataFrame includes:
- Feature columns, which can be either numeric or categorical.
- A target column
y, which indicates whether the problem is a binary classification or a continuous regression task.
Your task is to build and evaluate a machine learning model using only fundamental Python libraries.
Constraints
- You are restricted to using pandas and numpy, along with standard Python functionalities.
- You may use Google for documentation purposes.
- You are explicitly forbidden from using AI assistants or high-level machine learning libraries (e.g., scikit-learn, TensorFlow, PyTorch).
Deliverables
-
Data Preparation:
- Implement a strategy to handle missing values within the dataset.
- Develop a method to encode categorical variables into a numerical format suitable for modeling.
- Split the dataset into training and validation sets, or implement a cross-validation scheme.
- Apply appropriate standardization or normalization techniques to features where necessary.
-
Modeling (from Scratch):
- Select a suitable baseline model based on the target variable type (e.g., linear regression for continuous targets, logistic regression for binary targets).
- Implement the chosen model's training process from scratch using
numpy, typically involving an optimization algorithm like gradient descent. - Implement the prediction function for your model.
-
Evaluation:
- Choose and justify appropriate evaluation metrics for your model (e.g., Mean Squared Error (MSE) or Root Mean Squared Error (RMSE) for regression; Accuracy, Precision, Recall, F1-score, or Area Under the Curve (AUC) for classification).
- Explain how you would detect overfitting in your model and describe the strategies you would employ to mitigate it.
-
Concept Questions: Be prepared to discuss and explain the following core machine learning concepts:
- The Bias-Variance Tradeoff.
- Regularization (L1 vs L2) and how it modifies the objective function.
- Strategies for handling class imbalance in classification problems.
- The importance and rationale behind feature scaling, including when and why it is applied.
- The concept of train/validation/test leakage and practical methods to avoid it.
AI interview prep
Core dilemma
Demonstrating a deep, fundamental understanding of machine learning algorithms and data preprocessing by implementing them from first principles using only low-level libraries (NumPy/Pandas), rather than relying on high-level abstractions.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Build a model using only pandas/numpy
Build a Machine Learning Model from Scratch using Pandas and NumPy
You are provided with a tabular dataset as a pandas DataFrame df. This DataFrame includes:
- Feature columns, which can be either numeric or categorical.
- A target column
y, which indicates whether the problem is a binary classification or a continuous regression task.
Your task is to build and evaluate a machine learning model using only fundamental Python libraries.
Constraints
- You are restricted to using pandas and numpy, along with standard Python functionalities.
- You may use Google for documentation purposes.
- You are explicitly forbidden from using AI assistants or high-level machine learning libraries (e.g., scikit-learn, TensorFlow, PyTorch).
Deliverables
-
Data Preparation:
- Implement a strategy to handle missing values within the dataset.
- Develop a method to encode categorical variables into a numerical format suitable for modeling.
- Split the dataset into training and validation sets, or implement a cross-validation scheme.
- Apply appropriate standardization or normalization techniques to features where necessary.
-
Modeling (from Scratch):
- Select a suitable baseline model based on the target variable type (e.g., linear regression for continuous targets, logistic regression for binary targets).
- Implement the chosen model's training process from scratch using
numpy, typically involving an optimization algorithm like gradient descent. - Implement the prediction function for your model.
-
Evaluation:
- Choose and justify appropriate evaluation metrics for your model (e.g., Mean Squared Error (MSE) or Root Mean Squared Error (RMSE) for regression; Accuracy, Precision, Recall, F1-score, or Area Under the Curve (AUC) for classification).
- Explain how you would detect overfitting in your model and describe the strategies you would employ to mitigate it.
-
Concept Questions: Be prepared to discuss and explain the following core machine learning concepts:
- The Bias-Variance Tradeoff.
- Regularization (L1 vs L2) and how it modifies the objective function.
- Strategies for handling class imbalance in classification problems.
- The importance and rationale behind feature scaling, including when and why it is applied.
- The concept of train/validation/test leakage and practical methods to avoid it.