Home / Past papers / MLP End Term / this paper

What will be the output of the following block of code? 



What is the output of the following block of code? 



What is the output of the following code snippet?
Which of the options will be the correct output for the following code snippet? 



Which of the options will be the correct output for the following code snippet? 



Which of the following options is correct explained variance score for the following code snippet applying PCA technique.
Which of the following options is the correct output of the following block of code? 







Which of the following options represent the correct output of the following block of code? 




Which of the following options is the possible output for the following block of code?
What operation does the following code implement?
Which of the following options represent the recall value for the class 2 in the confusion matrix shown in Figure 1 if y_true = [0, 1, 2, 2, 2], y_pred = [0, 0, 2, 2, 1] ?
Consider the following code block and mark the correct output.
Consider X and y as the training dataset. What will be the output of the following code?
Consider the following block of code and mark all possible correct options.
What will be the output of the following code block: 



Which of the following options represent the output of the following block of code? 



Which of the following statements will be true based on the following diagram?
Which of the following options is the correct output of the following block of code?
Which of the following is likely to be the correct output of the code given below?
For the following block of code, we get the output as 0.9875. How would the output change if we decrease max depth value ?:
Consider the following block of code and mark the correct option.
Consider the following code snippet. What value should we fill at the blank place, so that given code block creates graph as shown below:
Calculate the coefficient of determination (R2) [up to 1 decimal point] based on the following block of code.
In the given block of code, the Iris dataset having shape (150,4) has been loaded for model training. What do you think will be the output of the code given below?
Code snippet written below plots a graph for some dataset X as shown below. In the given dendrogram which sample is most similar to the sample having label as 1 ?

What will be the output of the following code?
What will be the output of the following code? 
Which of the following is likely to be the correct output:
Which of the following is/are true about the following block of the 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 the core topics, concepts, principles, and equations essential for the "Diploma Level: Machine Learning Practice" exam, based on the provided question paper. The summary is divided into key areas with clear explanations and equations (where applicable).
Loaders vs. Fetchers:
Bunch object (dictionary-like with keys: data, target, feature_names, DESCR).load_iris(), load_wine()).fetch_california_housing()).Synthetic Datasets:
make_blobs(): Generates isotropic Gaussian blobs for clustering.
X, y = make_blobs(n_samples=10, centers=3, n_features=2, random_state=0)
# Output shape: (n_samples, n_features) → (10, 2)| Function | Description | Example |
|---|---|---|
load_wine() | Load wine dataset. | data = load_wine(); print(data.data.shape) |
fetch_california_housing() | Fetch California housing dataset. | X, y = fetch_california_housing(return_X_y=True) |
make_blobs() | Generate synthetic clusters. | X, y = make_blobs(centers=3) |
| Transformer | Purpose | Example |
|---|---|---|
StandardScaler | Standardize features (mean=0, std=1). | scaler.fit(X); scaler.mean_ |
MaxAbsScaler | Scale by max absolute value. | transformer = MaxAbsScaler().fit(X) |
PolynomialFeatures | Generate polynomial/interaction features. | PolyFeatures(degree=2, interaction_only=True) |
add_dummy_feature | Add a column of ones (bias term). | add_dummy_feature(X) → prepends 1s. |
MultiLabelBinarizer | Convert labels to binary matrix. | mlb.fit_transform([(1,2), (3,)]) |
interaction_only=False):interaction_only=True: .| Method | Description | Example |
|---|---|---|
LeaveOneOut() | LOO cross-validation. | loo.split(X) → yields train/test indices. |
train_test_split() | Split data into train/test sets. | X_train, X_test, ... = train_test_split(X, y, test_size=0.2) |
LOO Example (for X = [1, 2, 3, 4]):
split# 1, [1 2 3] [0]
split# 2, [0 2 3] [1]
split# 3, [0 1 3] [2]
split# 4, [0 1 2] [3]| Metric | Formula | Example |
|---|---|---|
| R² Score | r2_score(y_true, y_pred) | |
| Confusion Matrix | TP, TN, FP, FN. | confusion_matrix(y_true, y_pred) |
| Recall | For class 2: |
| Predicted: 0 | Predicted: 1 | Predicted: 2 | |
|---|---|---|---|
| True: 0 | 1 | 0 | 0 |
| True: 1 | 1 | 0 | 0 |
| True: 2 | 0 | 1 | 2 |
SGDRegressor:
shuffle=True: Shuffles data every epoch.learning_rate='constant', eta0=1e-2: Fixed learning rate.LogisticRegression:
lbfgs.predict_proba()).Explained Variance Ratio:
X = [[1,1], [2,2]], output is [1., 0.].Hyperparameters:
max_depth: Maximum tree depth.min_samples_split: Minimum samples to split a node.min_samples_leaf: Minimum samples at a leaf.Effect of max_depth:
max_depth may decrease or maintain training score (never guaranteed to increase).Elbow Method:
Example:
wcss = []
for i in range(1, 11):
km = KMeans(n_clusters=i, random_state=10)
km.fit(X)
wcss.append(km.inertia_) # WCSS = inertiaMLPClassifier/Regressor:
hidden_layer_sizes=(a, b, c): 3 hidden layers with a, b, c neurons.n_layers_: Total layers = input + hidden + output.out_activation_: Default is softmax (classification) or identity (regression).Example:
VotingClassifier(
estimators=[('lr', LogisticRegression()), ('rf', RandomForestClassifier())],
voting='hard'
)BaggingClassifier:
base_estimator: Model to bag (e.g., SVC()).n_estimators: Number of base models.GridSearchCV:
cv: Number of cross-validation folds (must be ≥ 1).return_train_score: If True, includes training scores in cv_results_.n_clusters-1).Example Output:
KMeans(n_clusters=3, random_state=5).fit(X).labels_
# Possible output: [0 0 1 1 2 2]Dendrogram:
0 in the example).Perfect Classifier:
(0, 1).DummyRegressor:
strategy="mean": Always predicts the mean of y.y = [1, 2, 3], predictions = [2, 2, 2].RadiusNeighborsClassifier:
radius=1.0: Considers neighbors within Manhattan distance of 1.p=1: Manhattan distance; p=2: Euclidean.KNeighborsGraph:
kneighbors_graph(X): Adjacency matrix of neighbors.Consistency:
fit()/predict()/transform().Sensible Defaults:
LogisticRegression(solver='lbfgs')).Non-Proliferation of Classes:
Pipeline instead of custom wrappers).Composition:
Pipeline, FeatureUnion).Inspection:
model.coef_).