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" exam, along with Mermaid knowledge graphs to visualize relationships.
Scaling Techniques:
StandardScaler: Standardizes features to have mean=0 and variance=1.
MaxAbsScaler: Scales features by their maximum absolute value.
MinMaxScaler: Scales features to a specified range (default: [0, 1]).
Handling Missing Data:
SimpleImputer: Replaces missing values with mean, median, or mode.
SimpleImputer(strategy='mean')Encoding Categorical Data:
['cat', 'dog'] → [0, 1]).['red', 'blue'] → [[1, 0], [0, 1]]).[['a', 'b'], ['a']] → [[1, 1], [1, 0]]).Polynomial Features:
PolynomialFeatures: Generates polynomial and interaction features.
PolynomialFeatures(degree=2) creates .Pipelines and FeatureUnions:
Pipeline: Sequentially applies transformations and estimators.
Example:
Pipeline([('impute', SimpleImputer()), ('scale', StandardScaler())])FeatureUnion: Combines features from multiple transformers.
Example:
FeatureUnion([('poly', PolynomialFeatures()), ('pca', PCA())])PCA (Principal Component Analysis):
PCA(n_components=2)Linear Models:
Linear Regression:
Ridge (L2) and Lasso (L1) Regularization:
Logistic Regression:
liblinear (good for small datasets), sag (stochastic average gradient).Naive Bayes:
GaussianNB: Assumes features follow a normal distribution.
Support Vector Machines (SVM):
linear, rbf (Radial Basis Function), poly.SVC(kernel='rbf')Decision Trees:
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.Attributes:
feature_importances_: Importance of each feature.Ensemble Methods:
Bagging (e.g., RandomForest):
RandomForestClassifier(n_estimators=100)Boosting (e.g., AdaBoost, Gradient Boosting):
AdaBoostClassifier(base_estimator=DecisionTreeClassifier())Neural Networks (MLP):
MLPClassifier: Multi-layer perceptron for classification.
Parameters:
hidden_layer_sizes: Number of neurons in hidden layers (e.g., (100,)).activation: relu, tanh, logistic.alpha: L2 regularization strength.solver: adam, sgd.Clustering:
K-Means:
KMeans(n_clusters=3)Hierarchical Clustering:
complete, ward, single, average.Metrics:
Classification:
Regression:
GridSearchCV for hyperparameter tuning.KNeighborsClassifier:
Parameters:
n_neighbors: Number of neighbors to consider.weights: uniform or distance.metric: euclidean, manhattan.n_neighbors.CountVectorizer:
CountVectorizer() → outputs (n_documents, n_features).Partial Fit:
SGDClassifier, PassiveAggressiveClassifier).model.partial_fit(X_batch, y_batch)Class Weighting:
class_weight='balanced' in LogisticRegression or SVC.Save/load models with joblib or pickle:
from joblib import dump, load
dump(model, 'model.joblib')
model = load('model.joblib')Focus on Scikit-Learn APIs:
model.fit(X, y), model.predict(X_test)).Understand Hyperparameters:
C in SVM (regularization), n_estimators in Random Forest.Preprocessing Steps:
Evaluation Metrics:
Dimensionality Reduction:
Avoid Overfitting:
Pipelines:
Pipeline([('scaler', StandardScaler()), ('model', SVC())])).This summary covers all the essential topics, equations, and relationships needed to excel in the exam. Use the Mermaid graphs to visualize connections between concepts!