Uploaded by Vidyasagar Kumar

ml notes

advertisement
Difference between cost function and loss function:
The terms "cost function" and "loss function" are often used interchangeably, and their meanings can vary
slightly depending on the context. However, in general, there is a distinction between the two:
1. Cost Function:
• The cost function is a broader term that refers to a mathematical function used to quantify
the overall cost or error of a machine learning model.
• The cost function considers the entire training set and measures the discrepancy between
the predicted outputs and the true outputs for all training examples.
• The cost function provides a global measure of the model's performance and guides the
optimization process to find the best parameters for the model.
• It is typically used during the training phase to update the model's parameters and minimize
the overall cost or error.
2. Loss Function:
• The loss function is a specific form of the cost function that measures the error or
discrepancy between the predicted output and the true output for a single training example
or data point.
• The loss function is calculated for each individual training example, and the overall loss is
obtained by aggregating the losses from all the examples.
• The loss function provides a local measure of the model's performance for a single instance
and is used to guide the learning algorithm to update the model's parameters.
• It is commonly used in iterative optimization algorithms, such as gradient descent, where the
model parameters are adjusted in the direction that minimizes the loss.
types of classification error:
In classification tasks, where the goal is to assign data points to predefined classes or categories, errors can
occur during the classification process. Here are the types of classification errors that can arise:
1. False Positive (Type I Error):
• A false positive occurs when a data point is predicted to belong to a certain class, but it
actually belongs to a different class.
• It is a case where the model mistakenly identifies something as positive when it should be
negative.
• For example, in a medical diagnosis scenario, a false positive would be when a healthy
person is classified as having a disease.
2. False Negative (Type II Error):
• A false negative occurs when a data point is predicted to not belong to a certain class, but it
actually belongs to that class.
• It is a case where the model fails to identify something as positive when it should be positive.
• For example, in a medical diagnosis scenario, a false negative would be when a person with a
disease is classified as being healthy.
3. True Positive:
• A true positive occurs when a data point is correctly predicted to belong to a certain class,
and it actually belongs to that class.
• It is a case where the model correctly identifies something as positive.
• For example, in a binary classification problem, a true positive would be when a model
correctly predicts a positive class.
4. True Negative:
• A true negative occurs when a data point is correctly predicted to not belong to a certain class, and it
actually does not belong to that class.
• It is a case where the model correctly identifies something as negative.
• For example, in a binary classification problem, a true negative would be when a model correctly predicts
a negative class.
These types of errors are inherent to classification tasks and can have different implications depending on the specific
application. The balance between minimizing false positives and false negatives depends on the cost and consequences
associated with each type of error. It is important to evaluate and consider these errors when assessing the performance
and reliability of a classification model.
define accuracy rate ,error rate, precesion,recall:
Accuracy Rate:
•
•
•
The accuracy rate, also known as classification accuracy, is a measure of how accurately a
classification model correctly predicts the class labels of the data points.
It is calculated as the ratio of the number of correctly classified instances to the total number of
instances in the dataset.
Accuracy rate provides an overall measure of the model's performance and is commonly used as a
basic evaluation metric. However, it can be misleading in imbalanced datasets where the classes
have different proportions.
Error Rate:
•
•
•
The error rate, also known as misclassification rate, is the complement of the accuracy rate. It
measures the proportion of misclassified instances in the dataset.
It is calculated as the ratio of the number of misclassified instances to the total number of instances
in the dataset.
The error rate provides an overall measure of the model's performance in terms of
misclassifications. A lower error rate indicates better performance.
Precision:
•
•
•
•
Precision is a measure of how accurately the positive predictions made by a model align with the
true positive instances.
It is calculated as the ratio of true positives to the sum of true positives and false positives.
Precision focuses on the relevance of the positive predictions and quantifies the model's ability to
avoid false positives.
A higher precision indicates a lower rate of false positive predictions.
Recall (Sensitivity or True Positive Rate):
•
•
•
•
Recall measures the ability of a model to correctly identify positive instances from the total actual
positive instances.
It is calculated as the ratio of true positives to the sum of true positives and false negatives.
Recall focuses on the completeness of the positive predictions and quantifies the model's ability to
avoid false negatives.
A higher recall indicates a lower rate of false negative predictions.
It's important to note that precision and recall are particularly useful in situations where class imbalance or
Inductive Bias:
•
•
•
•
In machine learning, inductive bias refers to the inherent assumptions or beliefs that a learning algorithm makes
about the relationship between the input data and the target output.
It represents the prior knowledge or biases that guide the learning process and influence the types of hypotheses the
algorithm considers.
Inductive bias helps the learning algorithm generalize from the training data to make accurate predictions on unseen
data.
The choice of inductive bias can affect the learning algorithm's ability to find a good hypothesis and its performance
on different datasets.
Hypothesis Space:
•
•
•
•
Hypothesis space, also known as the search space, is the set of all possible hypotheses that a learning algorithm can
consider to explain the relationship between the input data and the output.
It represents the range of possible solutions or models that the algorithm explores during the learning process.
The hypothesis space defines the set of candidate models from which the learning algorithm selects the most
appropriate hypothesis that fits the training data.
The size and complexity of the hypothesis space impact the learning algorithm's ability to find the true underlying
relationship and the trade-off between underfitting and overfitting.
Bias and variance and trade-off :
Machine learning is a branch of Artificial Intelligence, which allows machines to perform data analysis and make
predictions. However, if the machine learning model is not accurate, it can make predictions errors, and these
prediction errors are usually known as Bias and Variance. In machine learning, these errors will always be present as
there is always a slight difference between the model predictions and actual predictions. The main aim of ML/data
science analysts is to reduce these errors in order to get more accurate results. In this topic, we are going to discuss
bias and variance, Bias-variance trade-off, Underfitting and Overfitting. But before starting, let's first understand what
errors in Machine learning are?
Bias:
•
•
•
•
Bias refers to the error introduced by approximating a real-world problem with a simplified model or making
assumptions about the underlying relationship between the features and the target variable.
A model with high bias tends to oversimplify the problem and may not capture the complexity or nuances present in
the data.
High bias often leads to underfitting, where the model fails to capture the underlying patterns and performs poorly on
both the training and test data.
Bias measures the difference between the average prediction of the model and the true value of the target variable. It
represents the systematic error of the model.
Variance:
•
•
•
•
Variance refers to the variability or sensitivity of a model's predictions to changes in the training data.
A model with high variance is highly sensitive to the training data and can overfit the training set by capturing noise or
random fluctuations in the data.
High variance leads to poor generalization, where the model performs well on the training data but fails to generalize
to new, unseen data.
Variance measures the variability of the model's predictions when trained on different subsets of the data. It
represents the model's flexibility and ability to capture the noise in the training data.
Bias-Variance Trade-off:
•
•
•
•
Bias and variance are inversely related, and there is a trade-off between them.
Increasing the complexity of a model reduces bias but increases variance, and vice versa.
Finding the right balance between bias and variance is crucial for building a well-performing model.
The goal is to minimize both bias and variance, leading to a model that can capture the underlying patterns in the data
without overfitting or underfitting.
Download