Home / Past papers / MLP End Term / this paper
What will be the output of the following code:
What will be the numerical value in the output array of the following code: 












Given the following code snippet that preprocesses a dataset with both continuous and categorical features using sklearn.preprocessing tools, what will be the first row of the X transformed array after preprocessing? 





















You’re working on a binary classification task using the ‘MLPClassifier’ to predict whether a customer will make a purchase based on their browsing behavior.You’re concerned about overfitting due to the complexity of the model. You decide to increase the ‘alpha’ parameter to control overfitting. The following code snippet shows the application of ‘MLPClassifier’: 
Using the confusion matrix given below. What is the precision score for the label (class) 1 ? 

Fill in the missing parameter value in the following estimator that can be used to classify the data 






















You’re working with a dataset of customer purchase behavior, including attributes “Total Amount Spent” and “Number of Items Purchased.” You decide to use K-means clustering to segment customers into groups based on these features. The following code snippet demonstrates the K-means clustering process: 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 domains and includes key equations where applicable.
Scaling/Normalization:
StandardScaler: Standardizes features to have mean = 0 and variance = 1.
where = mean, = standard deviation.
MaxAbsScaler: Scales features by their maximum absolute value (range: ).
MinMaxScaler: Scales features to a specified range (default: ).
Encoding Categorical Data:
["cat", "dog"] → [0, 1]).["large", "cold"] → [1, 0, 1, 0]).Handling Missing Data:
SimpleImputer: Replaces missing values with mean, median, or mode.
strategy='mean' replaces NaN with the column mean.Polynomial Features:
PolynomialFeatures: Generates polynomial/interaction features (e.g., ).
degree=n (max polynomial degree).interaction_only=True (only interaction terms, no higher-order polynomials).Feature Union & Pipelines:
PCA (Principal Component Analysis):
n_components=k (number of principal components to keep).Linear Regression:
Ridge (L2) & Lasso (L1) Regularization:
Logistic Regression:
C (inverse of ) controls strength.Solvers:
liblinear: Good for small datasets, supports .lbfgs: Default, fast for large datasets (only ).sgd: Stochastic Gradient Descent (supports partial_fit).GaussianNB: Assumes features follow a normal distribution.
SVC (Support Vector Classifier):
Kernel Trick: Maps data to higher dimensions for linear separation.
linear, rbf (Gaussian), poly, sigmoid.C controls margin hardness.DecisionTreeClassifier:
Splitting Criteria:
Hyperparameters:
max_depth: Limits tree depth.min_samples_split: Min samples required to split a node.min_samples_leaf: Min samples required in a leaf.Random Forest:
Hyperparameters:
n_estimators: Number of trees.max_features: Features considered for splitting (default: sqrt(n_features)).bootstrap: Whether to use bootstrapping.AdaBoost:
Hyperparameters:
n_estimators: Number of weak learners.learning_rate: Shrinks contribution of each tree.Gradient Boosting (GBM, XGBoost, LightGBM):
Hyperparameters:
learning_rate: Step size shrinkage.n_estimators: Number of boosting stages.MLPClassifier (Multi-Layer Perceptron):
Architecture:
Activation Functions:
Hyperparameters:
hidden_layer_sizes: Number of neurons per layer (e.g., (100, 50)).alpha: regularization strength.activation: relu, tanh, logistic.Overfitting Control:
alpha (regularization).hidden_layer_sizes.KNeighborsClassifier:
euclidean, manhattan, minkowski.Hyperparameters:
n_neighbors: Number of neighbors to consider.weights: uniform (all neighbors equal) or distance (weight by inverse distance).Decision Boundary:
n_neighbors → complex boundaries (prone to overfitting).n_neighbors → smooth boundaries (prone to underfitting).where = learning rate.
K-Means:
Steps:
Hyperparameters:
n_clusters: Number of clusters ().Hierarchical Clustering:
Linkage Methods:
DBSCAN (Density-Based):
Hyperparameters:
eps: Max distance between points to be considered neighbors.min_samples: Min points to form a dense region.PCA (Principal Component Analysis):
Classification Metrics:
Regression Metrics:
where , .
Bias-Variance Tradeoff:
GridSearchCV:
RandomizedSearchCV:
GridSearchCV for large spaces.Partial Fit:
Supported by:
SGDClassifier/SGDRegressorPassiveAggressiveClassifierPerceptronMultinomialNB/BernoulliNBBagging (Bootstrap Aggregating):
RandomForest, BaggingClassifier).Boosting:
AdaBoost, GradientBoosting).Stacking:
CountVectorizer:
TF-IDF (Term Frequency-Inverse Document Frequency):
where:
Feature Importance: