ML Exam

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Q1. What are different types of Machine Learning?

Machine Learning is defined as the study of computer programs that leverage


algorithms and statistical models to learn through inference and patterns without being
explicitly programed.
Types of Machine Learning –
1. Supervised Learning
2. Unsupervised Learning
3. Reinforcement Learning

 Supervised Learning –

Supervised learning is one of the most basic types of machine learning. In this type, the
machine learning algorithm is trained on labeled data. Even though the data needs to be
labeled accurately for this method to work, supervised learning is extremely powerful
when used in the right circumstances.
In supervised learning, the ML algorithm is given a small training dataset to work with.
This training dataset is a smaller part of the bigger dataset and serves to give the
algorithm a basic idea of the problem, solution, and data points to be dealt with. The
training dataset is also very similar to the final dataset in its characteristics and provides
the algorithm with the labeled parameters required for the problem.

 Unsupervised Learning –

Unsupervised machine learning holds the advantage of being able to work with
unlabeled data. This means that human labor is not required to make the dataset
machine-readable, allowing much larger datasets to be worked on by the program.
In supervised learning, the labels allow the algorithm to find the exact nature of the
relationship between any two data points. However, unsupervised learning does not
have labels to work off of, resulting in the creation of hidden structures. Relationships
between data points are perceived by the algorithm in an abstract manner, with no
input required from human beings.
The creation of these hidden structures is what makes unsupervised learning algorithms
versatile. Instead of a defined and set problem statement, unsupervised learning
algorithms can adapt to the data by dynamically changing hidden structures. This offers
more post-deployment development than supervised learning algorithms.

 Reinforcement Learning –

Reinforcement learning directly takes inspiration from how human beings learn from
data in their lives. It features an algorithm that improves upon itself and learns from
new situations using a trial-and-error method. Favorable outputs are encouraged, or
‘reinforced’, and non-favorable outputs are discouraged or ‘punished’.
Based on the psychological concept of conditioning, reinforcement learning works by
putting the algorithm in a work environment with an interpreter and a reward system.
In every iteration of the algorithm, the output result is given to the interpreter, which
decides whether the outcome is favorable or not.
In case of the program finding the correct solution, the interpreter reinforces the
solution by providing a reward to the algorithm. If the outcome is not favorable, the
algorithm is forced to reiterate until it finds a better result. In most cases, the reward
system is directly tied to the effectiveness of the result.
In typical reinforcement learning use-cases, such as finding the shortest route between
two points on a map, the solution is not an absolute value. Instead, it takes on a score of
effectiveness, expressed in a percentage value. The higher this percentage value is, the
more reward is given to the algorithm. Thus, the program is trained to give the best
possible solution for the best possible reward.

Q2. Explain in detail 3 Linear regression metrics?

The three Linear regression metrics are:


1. Mean Squared Error (MSE).
2. Root Mean Squared Error (RMSE).
3. Mean Absolute Error (MAE)

Mean Squared Error (MSE):

The MSE is calculated as the mean or average of the squared differences between
predicted and expected target values in a dataset.
 MSE = 1 / N * sum for i to N (y_i – yhat_i)^2
Where y_i is the i’th expected value in the dataset and yhat_i is the i’th predicted value.
The difference between these two values is squared, which has the effect of removing
the sign, resulting in a positive error value.
The squaring also has the effect of inflating or magnifying large errors. That is, the larger
the difference between the predicted and expected values, the larger the resulting
squared positive error. This has the effect of “punishing” models more for larger errors
when MSE is used as a loss function. It also has the effect of “punishing” models by
inflating the average error score when used as a metric.

Root Mean Squared Error (RMSE):

The Root Mean Squared Error, or RMSE, is an extension of the mean squared error.
Importantly, the square root of the error is calculated, which means that the units of the
RMSE are the same as the original units of the target value that is being predicted.

For example, if your target variable has the units “dollars,” then the RMSE error score
will also have the unit “dollars” and not “squared dollars” like the MSE.

As such, it may be common to use MSE loss to train a regression predictive model, and
to use RMSE to evaluate and report its performance.

The RMSE can be calculated as follows:


 RMSE = sqrt(1 / N * sum for i to N (y_i – yhat_i)^2)
Where y_i is the i’th expected value in the dataset, yhat_i is the i’th predicted value,
and sqrt() is the square root function.

We can restate the RMSE in terms of the MSE as:


 RMSE = sqrt(MSE)

Mean Absolute Error:

Mean Absolute Error, or MAE, is a popular metric because, like RMSE, the units of the
error score match the units of the target value that is being predicted.

Unlike the RMSE, the changes in MAE are linear and therefore intuitive. That is, MSE and
RMSE punish larger errors more than smaller errors, inflating or magnifying the mean
error score. This is due to the square of the error value. The MAE does not give more or
less weight to different types of errors and instead the scores increase linearly with
increases in error.

As its name suggests, the MAE score is calculated as the average of the absolute error
values. Absolute or abs() is a mathematical function that simply makes a number
positive. Therefore, the difference between an expected and predicted value may be
positive or negative and is forced to be positive when calculating the MAE.

The MAE can be calculated as follows:


 MAE = 1 / N * sum for i to N abs(y_i – yhat_i)
Where y_i is the i’th expected value in the dataset, yhat_i is the i’th predicted value
and abs() is the absolute function.

Q3. What are different metrics for classification algorithms? Explain 3 in detail.
Different metrics for classification algorithms are:
1. Confusion Matrix
2. Accuracy
3. Recall

Confusion Matrix:
The Confusion matrix is one of the most intuitive and easiest metrics used for finding
the correctness and accuracy of the model. It is used for Classification problem where
the output can be of two or more types of classes.

Actual
Positives (1) Negatives (0)
TP FP
Positives (1)
TN FN
Negatives (0)

Terms associated with Confusion matrix:


1. True Positives (TP): True positives are the cases when the actual class of the data
point was 1(True) and the predicted is also 1(True).

Ex: The case where a person is actually having cancer (1) and the model classifying his
case as cancer (1) comes under True positive.

2. True Negatives (TN): True negatives are the cases when the actual class of the
data point was 0(False) and the predicted is also 0(False).

Ex: The case where a person NOT having cancer and the model classifying his case as
Not cancer comes under True Negatives.

3. False Positives (FP): False positives are the cases when the actual class of the data
point was 0(False) and the predicted is 1(True). False is because the model has
predicted incorrectly and positive because the class predicted was a positive one
(1).

Ex: A person NOT having cancer and the model classifying his case as cancer comes
under False Positives.

4. False Negatives (FN): False negatives are the cases when the actual class of the
data point was 1(True) and the predicted is 0(False). False is because the model
has predicted incorrectly and negative because the class predicted was a negative
one (0).
Ex: A person having cancer and the model classifying his case as No-cancer comes under
False Negatives.

You might also like