## Locally weighted regression :

Locally weighted regression (LWR) is a machine learning technique that allows for non-linear regression models to be fit to data. It does this by weighting the data points in a given region differently, allowing for more flexibility in the model.

One example of LWR in action is in predicting housing prices. In this scenario, LWR can be used to model the relationship between a house’s square footage and its price. However, instead of fitting a single regression line to the entire dataset, LWR creates multiple regression lines for different regions of the data. For instance, a line may be fit to houses with square footage between 1,000 and 1,500, while another line may be fit to houses with square footage between 1,500 and 2,000. This allows the model to account for the fact that the relationship between square footage and price may not be the same across all regions.

Another example of LWR is in medical diagnosis. In this scenario, LWR can be used to predict the likelihood of a patient having a certain disease based on their symptoms and medical history. However, instead of fitting a single regression line to all patients, LWR creates multiple lines for different subgroups of patients. For instance, a line may be fit to patients with a certain age range and gender, while another line may be fit to patients with a different age range and gender. This allows the model to account for the fact that the relationship between symptoms and disease likelihood may vary across different subgroups.

In both of these examples, LWR allows for more accurate predictions by accounting for non-linear relationships in the data. It does this by fitting multiple regression lines, each tailored to a specific region of the data, instead of a single line for the entire dataset. This allows the model to better capture the complexity of the underlying relationships in the data, leading to more accurate predictions.