U-4_IML
U-4_IML
Ans:
Regression Analysis:
The assumptions in regression analysis are conditions that must be met for the model to provide
reliable estimates and valid inferences.
• Simple Linear Regression: In this simple linear regression there is only one dependent
and one independent variable. This linear regression model only one predictor.
▪ The mathematical equation for the simple linear regression model is
shown below.
▪ y=ax+b
o where y is a dependent variable
o x is a independent variable
o a, b are the regression coefficients
• Polynomial Regression: It analysis is a non-linear regression analysis. Polynomial
regression analysis helps for the flexible curve fitting of the data, involves the fitting of
polynomial equation of the data.
▪ The mathematical expression for the polynomail regression analysis is
shown below.
▪ y=a0+a1x+a2x^2+...........+anx^n
1. Model Overfitting or Underfitting: An overly complex model may fit the training
data too closely (overfitting) and fail to generalize, while a simple model may miss
patterns (underfitting).
2. Outliers and Influential Points: Outliers can heavily skew results, especially in small
datasets, affecting the accuracy of the model.
3. Missing Data: Missing values can bias the model or reduce the power of analysis if not
handled correctly.
Ans:
Linear regression:
Linear regression is a type of supervised machine learning algorithm that computes the linear
relationship between the dependent variable and one or more independent features by fitting a
linear equation to observed data.
Linear regression is a statistical method that models the relationship between two variables by
fitting a straight line to the data. This line, known as the "line of best fit," is used to make
predictions.
For example, imagine you want to predict someone’s monthly expenses based on their income.
Using linear regression, you plot income on the x-axis and expenses on the y-axis. The
regression model will calculate the best-fitting line through these points. With this line, you
can predict a person’s expenses for a given income.
y=mx+by=mx+b
where:
• yy is the predicted value (e.g., expenses),
• xx is the input variable (e.g., income),
• mm is the slope of the line (how much yy changes with each unit increase in xx),
• bb is the y-intercept (the value of yy when xx is 0).
Applications:
ADVANTAGES:
• Linear regression often serves as a good baseline model for comparison with more
complex machine learning algorithms.
• Linear regression assumes that the features are already in a suitable form for the
model. Feature engineering may be required to transform features into a format that
can be effectively used by the model.
3.With relevant examples In detail explain about Multiple Linear
Regression. Write the basic formula and calculation procedure for Multiple
Linear Regression. List out the difference between Linear Regression and
Multiple Regression. Mention the Applications, Advantages and
disadvantages of Multiple Linear Regression.
Ans:
Multiple linear regression is a style of predictive analysis that is frequently used. You can
comprehend the relationship between such a continuous dependent variable and two or more
independent variables using this kind of analysis.
Multiple regression analysis allows for the simultaneous control of several factors that affect
the dependent variable. The link between independent variables and dependent variables can
be examined using regression analysis.
Let k stand for the quantity of variables denoted by the letters x1, x2, x3… xk.
To use this strategy, we must suppose that we have k independent variables that we may set.
These variables will then probabilistically decide the result Y.
Example:
Imagine you are trying to predict the price of a house (yyy) based on:
Price =50,000+200⋅(Size)−5,000⋅(Distance)+10,000⋅(Bedrooms)
If a house is 1500 sq. ft., 3 bedrooms, and 10 miles from the city:
Price = 50,000+200⋅1500−5000⋅10+10,000⋅3=305,00
Multiple linear regression is preferable than basic linear regression when predicting the result
of a complex process.The relationship between two variables in straightforward relationships
can be precisely captured by a straightforward linear regression. However, multiple linear
regression can identify more intricate interactions that demand deeper analysis.
Multiple independent variables are used in a multiple regression model. It can match curved
and non-linear connections since it is not constrained by the same issues as the simple
regression equation. The uses of multiple linear regression are as follows.
• Forecasting or prediction
It can be fascinating and helpful to estimate relationships between variables. The multiple
regression model evaluates relationships between variables in terms of their capacity to forecast
the value of the dependent variable, just like all other regression models do.
Applications:
• Captures Non-Linearity
• Easy to Implement
• Flexible and Interpretable
• Enhances Prediction Accuracy
Limitations:
• Overfitting
• Sensitivity to Outliers
• Lack of Extrapolation Power
• Computational Complexity
• Interpretability Issues
4.How does a Polynomial Regression work? Explain polynomial regression
with real life example. How to overcome the problem of Over fitting and
under fitting in Polynomial Regression? Mention the Applications,
Advantages and Limitations of Polynomial Regression.
Ans:
Polynomial Regression:
It is a form of linear regression in which the relationship between the independent variable x
and dependent variable y is modelled as an nth-degree polynomial. Polynomial regression fits
a nonlinear relationship between the value of x and the corresponding conditional mean of y,
denoted E(y | x).
If we observe closely then we will realize that to evolve from linear regression to polynomial
regression. We are just supposed to add the higher-order terms of the dependent features in the
feature space. This is sometimes also known as feature engineering but not exactly.
Now, let’s apply polynomial regression to model the relationship between years of
experience and salary. We’ll use a quadratic polynomial (degree 2) for this example.
Salary= 0 + 1×Experience+2×Experience^2+….
Now, to find the coefficients that minimize the difference between the predicted salaries and
the actual salaries in the dataset we can use a method of least squares. The objective is to
minimize the sum of squared differences between the predicted values and the actual values.
Polynomial regression often leads to overfitting when the model's complexity increases to fit
the training data too closely, resulting in poor performance on new data. To address this,
regularization techniques like Ridge and Lasso regression are used. These methods penalize
large model weights, reducing overfitting by discouraging overly complex models. Ridge
regression minimizes the sum of squared weights, while Lasso regression encourages sparsity
by driving some weights to zero, simplifying the model. Regularization ensures a balance
between fitting the training data and maintaining generalization to unseen data.
Application:
The reason behind the vast use cases of the polynomial regression is that approximately all
of the real-world data is non-linear in nature and hence when we fit a non-linear model on
the data or a curvilinear regression line then the results that we obtain are far better than what
we can achieve with the standard linear regression. Some of the use cases of the Polynomial
regression are as stated below:
Advantages:
Disadvantages:
• The presence of one or two outliers in the data can seriously affect the results of
nonlinear analysis.
• In addition, there are unfortunately fewer model validation tools for the detection of
outliers in nonlinear regression than there are for linear regression.
5.What are odds? Why is it used in logistic regression? With an example,
describe How we can solve multiclass classification problem using Logistic
Regression? Discuss assumptions in logistic regression. Mention the
Applications, Advantages and Limitations of Logistic Regression.
Ans:
Odds:
Odds represent the ratio of the probability of an event occurring to the probability of it not
occurring. Mathematically:
Odds=𝑃(event)/1−𝑃(event)
In logistic regression, odds are used because the model predicts probabilities of outcomes, and
the log of the odds (logit) provides a linear relationship between the predictors and the target.
This makes it easier to estimate parameters and interpret the relationship between variables.
Logistic regression is inherently a binary classifier, but multiclass problems can be solved using
techniques like:
• One-vs-Rest (OvR): The problem is divided into multiple binary classification tasks,
where one class is treated as the positive class and all others as negative. For example,
to classify handwritten digits (0-9), 10 binary classifiers are trained, one for each digit.
• One-vs-One (OvO): A binary classifier is trained for every pair of classes. For
example, for classifying digits, classifiers for (0 vs 1), (0 vs 2), (1 vs 2), and so on are
created, resulting in (10/2)=45 classifiers. The final prediction is based on a voting
mechanism.
Assumptions:
❖ Independent observations: Each observation is independent of the other. meaning
there is no correlation between any input variables.
❖ Binary dependent variables: It takes the assumption that the dependent variable must
be binary or dichotomous, meaning it can take only two values.
❖ Linearity relationship between independent variables and log odds: The
relationship between the independent variables and the log odds of the dependent
variable should be linear.
❖ No outliers: There should be no outliers in the dataset.
❖ Large sample size: The sample size is sufficiently large
Applications:
❖ Healthcare: Predicting the presence of a disease (e.g., diabetes or cancer detection).
❖ Marketing: Classifying customer responses (e.g., whether they will purchase a product
or not).
❖ Finance: Assessing credit risk or likelihood of loan default.
❖ Education: Predicting student performance or dropout risk.
❖ Social Science: Modeling voting behavior or survey responses.
Advantages:
• Simplicity and Interpretability
• Efficiency
• Probability Output
• Works Well with Linearly Separable Data
• Less Prone to Overfitting
Disadvantages:
• Linear Decision Boundaries
• Sensitive to Outliers
• Assumes Independence of Features
• Limited to Binary and Multiclass Classification
• Requires Large Datasets
6.Write the Difference Between Probability and Likelihood. In detail explain
the concept of Maximum Likelihood Estimation with an example.Mention
the Applications, Advantages and disadvantages of Maximum likelihood
estimation.
Ans:
Whereas probability, in simple words is a term that describes the chance of some event or thing
happening concerning other circumstances or conditions, mostly known as conditional
probability.
Also, the sum of all the probabilities associated with a particular problem is one and can not
exceed it, whereas the likelihood can be greater than one.
Example:
The maximum likelihood estimation is a base of some machine learning and deep learning
approaches used for classification problems. One example is logistic regression, where the
algorithm is used to classify the data point using the best-fit line on the graph.
As shown in the above image, all the data observations are plotted in a two-dimensional
diagram where the X-axis represents the independent column or the training data, and the y-
axis represents the target variable. The line is drawn to separate both data observations,
positives and negatives. According to the algorithm, the observations that fall above the line
are considered positive, and data points below the line are regarded as negative data points.
Applications:
• Machine Learning: MLE is used to estimate the parameters of various models,
including logistic regression, Naive Bayes, and hidden Markov models.
• Econometrics: It helps in estimating the parameters of economic models, such as
demand and supply functions.
• Reliability Engineering: Used to estimate the failure rates of systems and components.
• Signal Processing: MLE is applied to estimate parameters in signal noise models, such
as in radar or communication systems.
Advantages:
• Asymptotically Efficient
• Flexibility
• Consistent
• Statistical Inference
• Broad Applicability
Disadvantages:
• Computational Complexity
• Sensitivity to Outliers
• Requires Large Sample Sizes
• Model Assumptions
• Local Maxima