Home / Past papers / MLP End Term / this paper
Consider following common data and answer the subquestions:
What will be the output of the following code snippet? Enter -1, if you think the above code snippet will generate an error.
What will be the output of the following code snippet? Enter -1, if you think the above code snippet will generate an error.
What will be the output of the following code snippet? Enter -1, if you think the above code snippet will generate an error.
What will be the output of the following code snippet? Enter -1, if you think the above code snippet will generate an error.
Consider following parameter grid for regression with RandomForest: How many unique combinations of hyperparameters are there in the above parameter grid?

















































What will be the output of the following code?
What will be the output of the following code? Auto-generated summary from the source site. Handy as a checklist; the lessons above explain each idea from scratch.
Here’s a structured summary of core topics, concepts, principles, and equations essential for the Diploma Level: Machine Learning Practice (Computer-Based Exam). The exam covers Pandas, Scikit-Learn, ML algorithms, hyperparameter tuning, evaluation metrics, and clustering. Key areas are data preprocessing, model training, evaluation, and interpretation of results.
DataFrame Basics:
pd.DataFrame(data, columns)df.shape → (rows, columns)df.isna().sum().sum() → Total missing values.df.value_counts() → Frequency of unique values in a column.df.iloc[:, n] → Select column by index.df.query("condition") → Filter rows based on a condition.Handling Missing Data:
df.dropna() → Remove rows/columns with missing values.KNNImputer).Descriptive Statistics:
df.mean() → Column-wise mean (ignores NaN by default).Linear Regression:
Ridge/Lasso Regression:
Regularization:
Key Parameters:
alpha: Regularization strength (higher = more penalty).max_iter: Maximum iterations for convergence.Logistic Regression:
Class Weights:
class_weight='balanced' → Adjusts weights inversely proportional to class frequencies.Regularization:
C (inverse of alpha): Smaller C = stronger regularization.Perceptron:
Key Parameters:
tol: Tolerance for stopping criteria.shuffle: Whether to shuffle data between epochs.SGDClassifier/Regressor:
max_iter (default: 1000).hinge (SVM), log (logistic regression).Decision Trees:
Splitting Criteria:
Key Parameters:
max_depth: Maximum depth of the tree.min_samples_split: Minimum samples required to split a node.min_samples_leaf: Minimum samples required at a leaf node.Random Forest:
Key Parameters:
n_estimators: Number of trees.bootstrap: Whether to use bootstrapping for sample selection.Bagging & Boosting:
Bagging (e.g., BaggingClassifier):
Key Parameters:
max_samples: Number of samples per subset.bootstrap: Whether to sample with replacement.Boosting (e.g., AdaBoost, Gradient Boosting):
Key Concepts:
Kernel Trick: Transforms data into higher dimensions for linear separation.
C: Regularization parameter (trade-off between margin and classification error).kernel: linear, rbf, poly.Key Concepts:
Key Parameters:
n_neighbors: Number of neighbors to consider.weights: uniform or distance (closer neighbors have more influence).K-Means:
Key Parameters:
n_clusters: Number of clusters (k).init: Initialization method (random, k-means++).n_init: Number of times to run with different centroid seeds.Agglomerative Clustering:
ward, complete, average.Strategies:
most_frequent: Always predicts the majority class.stratified: Predicts class labels based on training distribution.Classification:
Regression:
where:
Leave-One-Out Cross-Validation (LOOCV):
n models (where n = number of samples).k-Fold Cross-Validation:
k folds, trains on k-1 folds, validates on the remaining fold.PolynomialFeatures:
Key Parameters:
degree: Highest polynomial degree.include_bias: Whether to include a bias term (intercept).StandardScaler):MinMaxScaler):Impacted Algorithms:
GridSearchCV:
Key Parameters:
param_grid: Dictionary of hyperparameters to tune.cv: Number of cross-validation folds.Example:
param_grid = {
'n_estimators': [10, 20, 30],
'max_features': [2, 3, 4],
'bootstrap': [True, False]
}
RandomizedSearchCV:
Soft Voting: Average of predicted probabilities.
VotingClassifier(estimators=[('lr', clf1), ('rf', clf2)], voting='soft')| Bagging | Boosting |
|---|---|
| Trains models in parallel. | Trains models sequentially. |
| Reduces variance (e.g., Random Forest). | Reduces bias (e.g., AdaBoost, XGBoost). |
| Uses bootstrapped samples. | Weights misclassified samples higher. |
Data Snooping:
Avoiding Leakage:
sklearn.pipeline.Pipeline).Eigenvectors of the covariance matrix = principal components.
| Concept | Equation |
|---|---|
| Linear Regression | |
| Ridge (L2) Regularization | |
| Lasso (L1) Regularization | |
| Logistic Regression | |
| Precision | |
| Recall | |
| F1-Score | |
| R² Score | |
| K-Means Inertia | |
| Standard Scaling | |
| Min-Max Scaling |
Pandas:
df.shape[0]*df.shape[1] - df.isna().sum().sum()).value_counts() for frequency tables.Scikit-Learn:
SGDRegressor(max_iter=1000)).make_pipeline for sequential preprocessing + modeling.model.score(X, y) returns for regression and accuracy for classification.Algorithms:
max_depth controls overfitting.C controls regularization; higher C = less regularization.n_neighbors affects bias-variance tradeoff (high n = smoother boundaries).Clustering:
inertia_ = within-cluster sum of squares.Evaluation Metrics:
strategy='most_frequent').Avoid Common Mistakes:
alpha in Ridge/Lasso vs. C in LogisticRegression/SVM (they are inverses!).voting='soft' requires estimators with predict_proba.