0% found this document useful (0 votes)
3 views

week7

The document covers key concepts in data science, focusing on hyperparameters, cross-validation methods, and classification techniques. It discusses logistic regression, its application in binary classification, and various performance metrics such as precision and accuracy. Additionally, it includes practical examples and questions related to model evaluation and ROC curves.

Uploaded by

yuvamaha65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

week7

The document covers key concepts in data science, focusing on hyperparameters, cross-validation methods, and classification techniques. It discusses logistic regression, its application in binary classification, and various performance metrics such as precision and accuracy. Additionally, it includes practical examples and questions related to model evaluation and ROC curves.

Uploaded by

yuvamaha65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Week 7

Session Co-Ordinator : Abhijit Bhakte


Parameter and Hyper parameter

Data Science for Engineers- TA Session 2


Example: Neural Network Model

Data Science for Engineers- TA Session 3


How to select hyparameters?

Data Science for Engineers- TA Session 4


Methods
• Leave one out cross validation (LOOCV) • K-fold cross validation

Data Science for Engineers- TA Session 5


Selection of hyperparameter
• Given graph is for the Neural
network model that predicts the
square of a number

• When cross validation is performed


the best hyper parameters are
chosen as 2 hidden layers with 10
neuron

Data Science for Engineers- TA Session 6


Q) What is the primary purpose of cross-validation in Solution
machine learning?
A) To train multiple models simultaneously for faster It helps in estimating how well a model
convergence. will perform on new, unseen data by
B) To evaluate a model's performance and assess its simulating the process of training and
generalization to unseen data. testing on different subsets of the data.
C) To increase the complexity of a model for better
accuracy.
D) To reduce overfitting by adding more training
data.

Q) Which of the following is not a commonly used Solution


cross-validation technique?
It involves splitting the dataset into two
A) K-Fold Cross-Validation
parts: a training set and a test set, where
B) Leave-One-Out Cross-Validation (LOOCV) the model is trained on the training set
C) Stratified Cross-Validation and evaluated on the test set. While it is
D) Train-Test Split a common method for evaluation, it is
not a cross-validation technique.
Q) Which statement best describes Leave-One-Out
Cross-Validation (LOOCV)?

A) It is computationally efficient for large datasets.


B) It divides the data into K subsets and uses K-folds
for training and 1 fold for testing.
C) It uses a single data point for testing and the
remaining data for training.
D) It is primarily used for time series data.

Q) Which of the following is an example of a Solution


hyperparameter?
A hyperparameter is a configuration
A) The weights of a neural network's hidden layers.
setting that is set before the model
B) The learning rate of an optimization algorithm. training begins
C) The input features of a dataset.
D) The training data used for model training.
Classification
 Classification is a supervised learning that assign class to the data points

 Examples:

 Email Spam Detection


 Sentiment Analysis
 Image Classification
 Medical Diagnosis
 Fraud Detection
 Language Identification

Data Science for Engineers- TA Session 9


Types of Classification
Binary classification Multiclass classification
Includes two Classes Includes more than two Classes

Data Science for Engineers- TA Session 10


Types of Classification
Linearly Separable Problem Non-linearly Separable Problem
Linear Boundary Nonlinear Boundary

Data Science for Engineers- TA Session 11


Logistic Regression
 Classification is the technique which draw linear boundary
 Goal: Given new sample data predict the class from
which the data point likely to have originated
 Simply guess of the class is not the good way to classify the sample
hence probability is introduces to provide better understanding

Data Science for Engineers- TA Session 12


How to model probability
 To classify the two classes we use decision boundary (linear equation)
 The value of equation may vary from (-inf to +inf)

 To bring this value in (0 to 1) range we use sigmoid function


sigmoid function

Data Science for Engineers- TA Session 13


Logistic Regression
 We have linear boundary equation

 Applying Sigmoid function

 To learn the model parameter


we use loss function

Data Science for Engineers- TA Session 14


How the model learns during training

Data Science for Engineers- TA Session 15


Q) What type of machine learning problem is Solution
logistic regression primarily used for?
Logistic regression is a classification
A) Regression algorithm used to model the probability
B) Classification of a binary outcome.
C) Clustering
D) Dimensionality Reduction

Q) In logistic regression, what is the output range of Solution


the logistic function (sigmoid function)?
The logistic function outputs probabilities
A) [-1, 1]
between 0 and 1, making it suitable for
B) [0, 1] binary classification.
C) [0, ∞)
D) (-∞, ∞)
Q) What is the purpose of the sigmoid function in Solution
logistic regression?
The sigmoid function is used to map the
A) To convert odds to probability. log-odds (logit) to a probability value
B) To model the linear relationship between features between 0 and 1.
and target.
C) To normalize the feature values.
D) To calculate the mean squared error.

Q) In logistic regression, what is the cost function Solution


that is minimized during training?
The cross-entropy loss, also known as log
A) Mean Absolute Error (MAE)
loss, is used as the cost function in logistic
B) Mean Squared Error (MSE) regression.
C) Cross-Entropy Loss (Log Loss)
D) Root Mean Square Error (RMSE)
Q) In logistic regression, how are model coefficients Solution
(weights) typically determined during training?
Gradient descent is commonly used to
A) Randomly initialized iteratively update model coefficients to
B) Calculated using gradient descent minimize the cost function.
C) Set to 1 for all features
D) Assigned based on feature importance

Q) Which evaluation metric is commonly used to Solution


assess the performance of a logistic regression
Logistic regression models are often
model?
evaluated using classification metrics
A) R-squared (R^2) such as accuracy, precision, recall, and
B) Mean Absolute Error (MAE) F1-Score, depending on the problem
C) Accuracy, Precision, Recall, F1-Score and requirements.
D) Root Mean Square Error (RMSE)
R Studio
◦ Wheat Dataset
◦ Input variables: Perimeter, Area, Compactness, length and width of
kernel …(# of features = 7)
◦ Output Labels: Seed Types (Types of seed = 3)

Data Science for Engineers- TA Session 19


Q) What is one-hot encoding used for in Solution
classification?
One-hot encoding is a technique used
A) Reducing the dimensionality of data. to represent categorical variables as
B) Encoding categorical variables as binary vectors. binary vectors to make them compatible
C) Scaling numerical features. with machine learning algorithms.
D) Visualizing data in scatter plots.

Q) In binary classification, what does precision Solution


measure?
Precision measures how many of the
A) The ability to correctly identify positive instances.
positive predictions made by a model
B) The ability to correctly identify negative instances. are actually correct, indicating the
C) The ratio of true positives to all positive model's ability to identify positive
predictions. instances accurately.
D) The ratio of true negatives to all negative
predictions.
Performance metric
Model

Actual Covid-Test Type

Positive Positive TP
Patient

Positive Negative FN
Negative Positive FP
Negative Negative TN

Data Science for Engineers- TA Session 21


Q) What is the purpose of a confusion matrix in Solution
classification?
A confusion matrix is used to evaluate
A) To visualize data in 3D space. the performance of a classification
B) To measure the accuracy of a regression model. model by providing information about
C) To assess the performance of a classification true positives, true negatives, false
model. positives, and false negatives.
D) To calculate the mean squared error.

Q) In binary classification, what does precision Solution


measure?
Precision measures how many of the
A) The ability to correctly identify positive instances.
positive predictions made by a model
B) The ability to correctly identify negative instances. are actually correct, indicating the
C) The ratio of true positives to all positive model's ability to identify positive
predictions. instances accurately.
D) The ratio of true negatives to all negative
predictions.
Q) In a binary classification problem, if a model Solution
makes 80 true positive predictions, 10 false positive
predictions, 5 false negative predictions, and 105 Acc = (TP+TN) / (Total Predictions)
true negative predictions, what is the accuracy of Acc = (80 + 105) / (80 + 10 + 5 + 105)
the model? Acc = 185 / 200 = 0.925
A) 0.44
B) 0.92
C) 0.96
D) 0.90

Q) A classification model predicts 120 instances as Solution


positive, out of which 100 are actually positive. What
Precision = (TP) / (TP+ FP)
is the precision of the model?
Precision = 100 / (100 + 20) = 0.83
A) 0.95
B) 0.90
C) 0.83
D) 0.75
ROC-(receiver operating characteristic) curve
 ROC Curve is a graphical representation of
a model's ability to distinguish between two
classes.
 Used in classification problems, particularly
in machine learning and medical diagnosis

Sensitivity
1-Specificity
Data Science for Engineers- TA Session 24
Q) If a classifier has a true positive rate of 0.90 and a Solution
false positive rate of 0.15, what is the specificity of
the classifier? Specificity = 1 - False Positive Rate
Specificity = 1 - 0.15 = 0.85
A) 0.15
B) 0.10
C) 0.85
D) 0.90

Q) A classification model has 120 true negatives Solution


and 30 false positives. What is the false positive rate
FPR = (FP) / (FP+TN)
of the model?
FPR = 30 / (30 + 120) = 0.2
A) 0.20
B) 0.25
C) 0.80
D) 0.10

You might also like