0% found this document useful (0 votes)
20 views5 pages

Similarity-Based Learning in BCS606

The document discusses similarity-based learning in machine learning, focusing on instance-based learning algorithms such as KNN, weighted KNN, and locally weighted regression. It explains the mechanics of these algorithms, including how KNN classifies new instances based on the similarity measure and how weighted KNN assigns weights to neighbors. Additionally, it covers the Nearest Centroid Classifier and the principles of Locally Weighted Regression, emphasizing their applications in classification and regression tasks.

Uploaded by

emanikanta535
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)
20 views5 pages

Similarity-Based Learning in BCS606

The document discusses similarity-based learning in machine learning, focusing on instance-based learning algorithms such as KNN, weighted KNN, and locally weighted regression. It explains the mechanics of these algorithms, including how KNN classifies new instances based on the similarity measure and how weighted KNN assigns weights to neighbors. Additionally, it covers the Nearest Centroid Classifier and the principles of Locally Weighted Regression, emphasizing their applications in classification and regression tasks.

Uploaded by

emanikanta535
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

MACHINE LEARNING(BCS606)

MODULE 3
CHAPTER 4
SIMILARITY-BASED LEARNING
4.1 Similarity or Instance-based Learning

4.1.1 Difference between Instance-and Model-based Learning

Some examples of Instance-based Learning algorithms are:


a) KNN
b) Variants of KNN
c) Locally weighted regression
d) Learning vector quantization
e) Self-organizing maps
f) RBF networks
Nearest-Neighbor Learning
• A powerful classification algorithm used in pattern recognition.
• K nearest neighbors stores all available cases and classifies new cases based on a
similarity measure (e.g distance function)
• One of the top data mining algorithms used today.
• A non-parametric lazy learning algorithm (An Instance based Learning method).
• Used for both classification and regression problems.

Deepa S, Dept. Of CSE,RNSIT 1


MACHINE LEARNING(BCS606)

Here, 2 classes of objects called C1


and C2. When given a test instance T,
the category of this test instance is
determined by looking at the class of
k=3 nearest neighbors. Thus, the
class of this test instance T is
predicted as C2.

Algorithm 4.1: k-NN

Deepa S, Dept. Of CSE,RNSIT 2


MACHINE LEARNING(BCS606)

4.3 Weighted k-Nearest-Neighbor Algorithm


The weighted KNN is an extension of [Link] chooses the neighbors by using the weighted
distance. In weighted kNN, the nearest k points are given a weight using a function called as
the kernel function. The intuition behind weighted kNN, is to give more weight to the points
which are nearby and less weight to the points which are farther away.

Deepa S, Dept. Of CSE,RNSIT 3


MACHINE LEARNING(BCS606)

4.4 Nearest Centroid Classifier


The Nearest Centroids algorithm assumes that the centroids in the input feature space are
different for each target label. The training data is split into groups by class label, then the
centroid for each group of data is calculated. Each centroid is simply the mean value of each
of the input variables, so it is also called as Mean Difference classifier. If there are two classes,
then two centroids or points are calculated; three classes give three centroids, and so on.

4.5 Locally Weighted Regression (LWR)


Locally Weighted Regression (LWR) is a non-parametric supervised learning algorithm that
performs local regression by combining regression model with nearest neighbor’s model.
LWR is also referred to as a memory-based method as it requires training data while prediction
but uses only the training data instances locally around the point of interest.
Using nearest neighbors algorithm, we find the instances that are closest to a test instance and
fit linear function to each of those ‘K’ nearest instances in the local regression model.
The key idea is that we need to approximate the linear functions of all ‘K’ neighbors that
minimize the error such that the prediction line is no more linear but rather it is a curve.
Ordinary linear regression finds out a linear relationship between the input x and the output y.
Given training dataset T,
Hypothesis function hβ(x), the predicted target output is a linear function where β0 is the
intercept and β1 is the coefficient of x.
It is given in Eq. (4.1) as,

The cost function is such that it minimizes the error difference between the predicted value
hβ(x) and true value ‘y’ and it is given as in Eq. (4.2).

where ‘m’ is the number of instances in the training dataset.


Now the cost function is modified for locally weighted linear regression including the
weights only for the nearest neighbor points. Hence, the cost function is given as in Eq. (4.3).

Deepa S, Dept. Of CSE,RNSIT 4


MACHINE LEARNING(BCS606)

Where wi is the weight associated with each xi


The weight function used is a Gaussian kernel that gives a higher value for instances that are
close to the test instance, and for instances far away, it tends to zero but never equals to zero.
wi is computed in Eq. (4.4) as,

Deepa S, Dept. Of CSE,RNSIT 5

Common questions

Powered by AI

Non-parametric methods like k-NN and LWR offer significant advantages in machine learning, particularly in their flexibility and ability to model complex relationships without prior assumptions about data distribution. k-NN classifies instances based directly on instance similarity or distance, making it useful for datasets where the underlying data distribution is unknown or hard to model parametrically . Similarly, LWR does not assume a global form of the underlying pattern and instead employs a locally adaptive approach that can capture intricate, locally varying trends within the data . In contrast, parametric methods require assumptions about the data distribution and are generally less flexible, potentially leading to over-simplified models that fail to capture complex patterns in variable data. Non-parametric methods thereby offer greater adaptability at the expense of requiring more computational power and typically larger storage needs due to direct instance storage. .

Locally Weighted Regression (LWR) differs from traditional linear regression by not assuming a global linear relationship across the entire dataset. Instead, LWR performs local regression by selecting instances closest to the test point and fitting a linear model to these local points, taking into account a distance-based weighting scheme that biases the fitting towards the points closest to the instance being predicted. This allows LWR to model more complex, nonlinear trends as the local linear models collectively approximate a locally curved line . Traditional linear regression, on the other hand, fits one global linear model to all the data, which may not capture local variability in complex datasets .

The memory-based nature of k-NN and LWR has a substantial impact on their practical application, primarily in terms of computational resources and scalability. Because these methods rely on storing and accessing the entire training dataset to classify or predict new instances, they require significant memory, and the computation time increases as the dataset grows . This can render them less efficient for large-scale datasets or real-time applications compared to model-based methods that compress the knowledge of the dataset into distinct parameters after training . Additionally, the need for frequent distance calculations in high-dimensional spaces can further exacerbate computational demands, making effective indexing strategies or dimensionality reduction techniques essential for their practical implementation .

The k-Nearest Neighbors (k-NN) algorithm is a non-parametric, lazy learning method that does not build a model from the training data. Instead, it stores all instances of the training data and classifies new cases based on a similarity measure, such as a distance function, between the new case and stored instances . In contrast, model-based learning methods build a proactive model that generalizes from training data to make predictions on new, unseen data, thus not requiring the storage and direct comparison of all training instances .

The Nearest Centroid Classifier can have limitations compared to k-NN, mainly due to its reliance on mean values, which might oversimplify the classification decision boundary. This method may lack the flexibility to capture complex class shapes in the feature space, particularly if the classes overlap significantly, leading to information loss that k-NN, which considers individual data points, can handle more adeptly . Additionally, the centroid approach can be more sensitive to outliers, as a few extreme values can skew the centroid position considerably, unlike k-NN, where the influence of outliers is mitigated by considering multiple nearby points .

Weighted k-Nearest-Neighbor differs from standard k-NN by assigning different weights to the nearest neighbors before making a prediction. This adaptation aims to give higher importance to instances closer to the test point, which is achieved using a kernel function that assigns weights based on distance, typically giving more influence to closer points. The intuition is that nearer points are likely more similar and thus should have more influence on the prediction . In standard k-NN, all neighbors contribute equally to the prediction irrespective of their distance from the test instance .

The Gaussian kernel in Locally Weighted Regression (LWR) is significant because it provides a smooth, non-zero weighting scheme that gives higher weights to training instances closer to the test instance, while gradually reducing the weight for further instances. This ensures that predictions are influenced more by nearby points, which are likely to share a similar local structure or trend, resulting in a more accurate local fit. Moreover, the weights never reach zero, avoiding the complete exclusion of any potential data influence . This feature of the Gaussian kernel helps LWR achieve a good trade-off between bias and variance in predictions .

The selection of 'k' in the k-Nearest Neighbors algorithm critically influences its performance by balancing bias and variance. A smaller 'k' makes the model sensitive to noise and potentially too complex, leading to high variance and overfitting as it may closely follow minor fluctuations in the data . Conversely, a larger 'k' results in a smoother and more generalized decision boundary, reducing the model's flexibility to capture local patterns, hence increasing bias and potentially underfitting the data . Therefore, 'k' must be carefully selected, often using techniques like cross-validation to determine an optimal value that provides a suitable balance tailored to the specific dataset's characteristics .

In the Nearest Centroid Classifier, the centroid represents the mean point of all the instances for each class in the feature space . For a dataset with multiple classes, a separate centroid is computed for each class by calculating the average of the input variables for that class. This results in as many centroids as there are classes. Each new instance is then classified based on which centroid it is nearest to in the feature space, effectively simplifying the decision boundary to a simple nearest distance calculation between the instance and the mean points of classes .

Locally Weighted Regression (LWR) implements an error minimization approach by adjusting weights of nearby instances using a distance-based kernel, such as a Gaussian kernel, which biases the fit toward nearer data points. This technique effectively minimizes local prediction errors by fitting a linear function to a subset of data instances closest to the prediction point, ensuring that the model adapts to local variations in data structure . The weight for each instance is calculated using its distance from the test instance, allowing LWR to approximate the local trend and reduce the prediction error in those specific regions .

You might also like