0% found this document useful (0 votes)
26 views13 pages

Linear Regression and Polynomial Fitting

This document appears to be about an assignment for a machine learning course. It includes 6 potential answers to coding and analysis questions related to topics like linear regression, polynomial regression, overfitting, and estimating classifiers from partially labeled data. The questions involve coding implementations of algorithms and analyzing their performance on various datasets.

Uploaded by

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

Linear Regression and Polynomial Fitting

This document appears to be about an assignment for a machine learning course. It includes 6 potential answers to coding and analysis questions related to topics like linear regression, polynomial regression, overfitting, and estimating classifiers from partially labeled data. The questions involve coding implementations of algorithms and analyzing their performance on various datasets.

Uploaded by

mostgole zannath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Machine Learning (Fall 2020)

Assignment 1

ANSWER No 1: Linear regression

We have learned about linear regression in the class. Here we explore what we mean by "linear".
Specifically, we will see how linear regression can be used to fit non-linear functions of the data using
feature maps, and explore some of its limitations.

Learning degree-3 polynomials of the input


N
1
J(θ)= ∑ ¿ ¿- y i)2

2 I=1

Differentiating this objective we get the update rule


N
∇ θj(θ )=∑ ¿¿ - y i)( x i)
I=1

N
∝ γ ∑ ¿ ¿- y i)( x i)
I=1

WHERE γ IS THE LEARING RATE THE UPDATE RULE IS


N
θ=θ ∑ ¿ ¿- y i)( x i)
I =1
Answer no 2: Coding question: degree-3 polynomials regression

Code

Output graph
3. Coding question: degree-3 polynomial GD and SGD

Output
Answer no 4: Coding question: degree-k polynomial regression

Output
Generally higher degree polynomials tend to fit the data better though very high degree poly-nominal’s
can be numerically unstable

Answer no 5: Coding question: other feature maps

Output
In the presence of the sin(x) feature, the models seem to the data better more robustly. However the
numerical instability that comes with high degree polynomials remain

Answer no 6 : Overfitting with expressive models and small data


We see that when the dataset is small. Higher degree polynomials tend to pass through all the
points, but qualitatively seem like a poor fit. Numerical instability with high degree polynomials
remain a problem even with small data, with or without sin(x).
2. Incomplete, Positive-Only Labels

2.1Coding problem: ideal (fully observed) case


Output

2.2 Coding problem: The naive method on partial labels


Output

[Link]-up with Bayes rule

4.CP8318 Only Question


We have
ρ ¿-1| x i)- ρ ( y (i )-1⋀ t (i)-1| x i) from previous sub –question
= ρ ¿-1| x i)- ρ ( ρ ¿-1 t (i)-1. x(i)
= ρ ¿-1| x i)∝
Dividing both sides by ∝,we have the desired result

5.CP8318 Only Question: Estimating


This is a solution that is easier to understand but it strongly relies on the assumption that
we made here. The Solution 2 below is less intuitive but can work for more general
settings than the setting in this sub question.

We fix i and let A –{x: ρ ¿ ¿-1| x(i)-x)-1} be the set of all positive examples and R={x: ρ ¿ ¿
=0 x(i)=x)=1} be the set of all negative examples. By the assumption ρ ¿ ¿ -1 x(i) )ϵ
{0,1},we know that A and B covers the who;e input [Link] first claim that ρ ¿ ∉ A. y i
=1)=[Link] is because when x(i) ∉ A. we have that x(i) ∈B,WHICH IMPLIES THAT ρ ¿ ¿ -
0 | x(i) - 1,ehich implies that ρ ¿ ¿ -1 | x(i) – 0.
Therefore the event x(i) ∉ A implies the event ¿ ¿=0 which implies that y i =0.
Thus ρ ¿ ∈ A| y i -1 =1.

By 2nd for x∈ A,We have that h(x)-α p¿ ¿ -1 x(i)-x)-α .that is p(h( x(i)-α x (i )-x)-1.
The implies that p(h( x(i) -α ∨x (i) -x. y (i )-1)-1.
Note that for any event [Link] any event F with positive probability p(E)-1 implies that
p(E|F)-1.
This is because p(E)-0 which implies p(E|F)-p(E∩ F )/p (F)-0)
p(h( x(i) )=α | y (i )=1= p(h( x(i))=α | y (i )=1. x(i) ∈ A). ρ ¿ A| y (i )=1……(4)
-1. ρ ¿ A| y (i )=1)

(by p(h( x(i))=α | x(i)=x. y (i )=1)=1}

-1.1 (because p(h( x(i)) ∈ A| y (i )-1)-1}….(5)


-1
Therefore Eh ( x(i)) y (i )-1)-α

Let g( x i)-p(t i-1| x i) By d) we have that


h(( x i)-∝ g ( x i)
Then we have that
E[ph( x i) y (i )=1=Eh ( x i)| y (i )−1]
Eh ( x i ) 1{ y (i)=1 }
= ()
p { y i −1 }

E [ E1 ( y −1 )| x ] h x
i i i
= BY ;LAW OF EXPECTION
E ¿¿
=E ¿ ¿
E g ( xi ) . g xi
=∝
E¿¿
=∝ (since g(. x i) ∈{0,1 }

6. Coding problem.
Using the validation set, estimate the constant α by averaging your classifier’s
predictions over all labeled examples in the validation set:

Output

Common questions

Powered by AI

Assumptions in simplified solutions constrain the applicability of models as they limit the scenarios where the model can effectively generalize. While these assumptions can lead to easier understanding and implementation, they often restrict the model's flexibility to adapt to real-world complexities or broader datasets, making them less useful in more general settings that deviate from the assumptions .

Bayes’ rule is fundamental in probabilistic machine learning, providing a framework for updating predictions or hypotheses given new data. It allows the combination of prior knowledge with observed evidence to derive posterior probabilities, particularly useful in classification problems where the goal is to determine the probability of a class label given input features. This probabilistic approach aids in understanding and constructing classifiers that are better grounded in statistical theory .

Approximate update rules in gradient descent and its variants provide a practical way to navigate complex error landscapes efficiently, especially in high-dimensional spaces. While these approximations can accelerate convergence and alleviate computational burdens, they might also converge to suboptimal solutions if not managed carefully with appropriate step sizes and convergence criteria. The balance between computational efficiency and convergence accuracy is crucial for effective model training .

Numerical instability in models, typically due to high-degree polynomials or ill-conditioned feature maps, results in drastic swings in predictions with small data changes, leading to unreliable outputs. To mitigate these effects, one can employ regularization techniques that penalize extreme coefficient magnitudes, use less complex models that avoid excessive polynomial degrees, or apply feature scaling and normalization to reduce numerical issues .

Feature maps can enhance the robustness of regression models by transforming the input data to a higher-dimensional space where linear models can capture complex patterns more effectively. For instance, using features like sine functions can improve the model’s fit to the data and reduce the impact of the limitations experienced with polynomial features alone, although numerical instability can still be a concern .

Linear regression can address non-linearities in data by employing feature maps that transform the original data into a new feature space where a linear relationship can be modeled more effectively. This means incorporating transformations of input features, such as polynomial features, which allow linear regression to fit more complex non-linear functions . However, using higher degree polynomials can introduce numerical instability, especially with smaller datasets .

To handle positive-only labels, one could use semi-supervised learning techniques that extrapolate from positive examples to infer likely negatives, or employ PU (positive-unlabeled) learning where the model simultaneously learns to discriminate between positive and negative classes from a dataset that contains only positive and unlabeled instances. Moreover, integrating domain knowledge or probabilistic constraints can help improve the robustness of classifications and predictions despite the lack of explicit negative labels .

A validation set provides an unbiased evaluation of a model's parameters, facilitating the estimation of hyperparameters like the constant α by allowing the model’s predictions to be tested on independent data. This helps avoid overfitting to the training data, ensuring that the parameter values are not overly tuned to specific idiosyncrasies of the training set, thereby enhancing model generalization to new, unseen data .

Overfitting occurs when a model learns the noise and random fluctuations in the training data rather than the underlying distribution. Expressive models like high-degree polynomials can fit the training data very closely but often perform poorly on unseen data, especially when the dataset is small. This is because such models capture specific patterns and outliers rather than the overall trend, leading to a qualitatively poor fit that doesn't generalize well .

High-degree polynomials in regression models can lead to several issues: numerical instability due to the high sensitivity of polynomial coefficients to small changes in input data, and a tendency to overfit the data by passing through all points in small datasets, which results in a poor generalization to new data . These drawbacks can undermine the model’s predictive performance and robustness .

You might also like