Home / Past papers / MLP End Term / this paper
Consider the following common data and answer the subquestion:
Consider the following code snippet: Which of the following will be equivalent to the above code snippet?




What is the output of the following code snippet: Enter -1, if you think the above statement will generate an error.
What is the output of the following code snippet: Enter -1, if you think the above statement will generate an error.
What is the output of the following code snippet: Enter -1, if you think the above statement will generate an error.
What is the output of the following code snippet: Choose correct options from following:























































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 the core topics, concepts, principles, and equations essential for the Diploma-Level Machine Learning Practice (Computer-Based Exam). The summary is organized by topic clusters for clarity, followed by Mermaid knowledge graphs to visualize relationships.
DataFrame Operations:
df.loc[] (label-based), df.iloc[] (position-based).df.loc[23:24, 'Maths':'History'] ≡ df.iloc[2:4, 1:3] (Q2).df.dropna() reduces rows (Q6).df.Hindi.apply(type).nunique() counts unique types (e.g., int, float, str) (Q4).Chunked Data Loading:
pd.read_csv("filename.csv", chunksize=1024, low_memory=False) (Q12).Train-Test Split:
train_test_split(X, y, test_size=30) for exact sample counts (Q25).test_size=0.2 (20% test data).Cross-Validation:
K-Fold CV: KFold(n_splits=3) splits data into 3 folds (Q9).
[3,4,5,6,7,8] vs [0,1,2]).sklearn.model_selection.learning_curve plots training/test errors vs. sample size (Q10).Metrics:
neg_mean_squared_error, r2 (Q26).accuracy, precision, recall, f1 (Q22).Decision Trees:
Hyperparameters:
max_depth: Controls tree depth (higher → overfitting) (Q20).min_samples_split: Minimum samples to split a node (Q36).min_samples_leaf: Minimum samples in a leaf (Q36).SVM (Support Vector Machines):
Naive Bayes:
partial_fit (Q11).k-Nearest Neighbors (k-NN):
k) (Q33).Ensemble Methods:
BaggingClassifier with DecisionTreeClassifier (Q23).learning_rate shrinks weak learner contributions (Q19).voting='soft' averages probabilities (Q22).Neural Networks (MLP):
MLPClassifier/MLPRegressor: Defines hidden layers via hidden_layer_sizes=(5,3) (2 layers with 5 and 3 neurons) (Q35).max_iter, learning_rate, alpha (L2 regularization).Stochastic Gradient Descent (SGD):
Loss Functions:
loss='log_loss' → Logistic regression (Q18).loss='hinge' → Linear SVM (Q17).loss='perceptron' → Perceptron (Q30).penalty='l1' (sparse weights) vs. penalty='l2' (Q17).warm_start=True enables incremental training (Q18).Clustering (K-Means):
Inertia: Sum of squared distances to centroids (Q24).
n_clusters = n_samples (Q38).n_clusters to find optimal k.Imbalanced Data:
Text Data:
CountVectorizer: Converts text to word-count matrices (Q14).
{'this': 4, 'is': 2}).Polynomial Features:
PolynomialFeatures(degree=2) adds interaction terms (Q16).param_grid = {'poly__degree': [2, 3, ...]}.Scaling:
MinMaxScaler or StandardScaler for SGD/neural networks (Q18).Handling Categorical Data:
Grid Search:
GridSearchCV: Exhaustively tests hyperparameter combinations (Q21).
param_grid = {'max_depth': [1,3,5], 'min_samples_split': [1,4,7]} → 15 combinations.Partial Fit:
model.partial_fit(X, y) (Q12, Q34).OpenML:
fetch_openml() (Q7).Model-Specific Notes:
SGDClassifier(loss='perceptron') is a stochastic perceptron (Q30).SGDClassifier(loss='log_loss') (Q30).y_true = [0.5, 0.2, 0.7, 1], y_pred = [0.4, 0.2, 1, 0.1] → 0.325.Pandas:
loc vs. iloc (Q2).dropna() affects rows/columns (Q6).Model Evaluation:
neg_mean_squared_error or r2 (Q26).accuracy or f1 (Q22).Algorithms:
max_depth (Q20).Hyperparameter Tuning:
GridSearchCV tests all combinations (Q21).param_grid with double underscores for pipelines (e.g., poly__degree) (Q16).SGD:
loss='log_loss' → Logistic regression (Q18).penalty='l1' → Sparse weights (Q17).Clustering:
n_clusters = n_samples (Q38).k (Q24).Text Data:
CountVectorizer outputs a vocabulary dictionary (Q14).Imbalanced Data:
Neural Networks:
hidden_layer_sizes=(5,3) → 2 layers (Q35).Code Snippets:
random_state in splits/models for reproducibility.warm_start=True enables incremental training (Q18).