# Boston house analysis

The source code: Boston House

## K-Neighbor-Nearst

In order to obtain results faster, we hope to obtain predictive power by fitting a function

$f(rm) = k * rm + b$

## Random Approach

$Loss(k, b) = \frac{1}{n} \sum_{i \in N} (\hat{y_i} - y_i) ^ 2$ $Loss(k, b) = \frac{1}{n} \sum_{i \in N} ((k * rm_i + b) - y_i) ^ 2$

## Monte Carlo simulation(蒙特卡洛模拟)

### Supervisor

$Loss(k, b) = \frac{1}{n} \sum_{i \in N} ((k * rm_i + b) - y_i) ^ 2$

$\frac{\partial{loss(k, b)}}{\partial{k}} = \frac{2}{n}\sum_{i \in N}(k * rm_i + b - y_i) * rm_i$

$\frac{\partial{loss(k, b)}}{\partial{b}} = \frac{2}{n}\sum_{i \in N}(k * rm_i + b - y_i)$

## Supervised Learning

We turn the forecast of housing prices into a more responsible and sophisticated model. What should we do?

$f(x) = k * x + b$

$f(x) = k2 * \sigma(k_1 * x + b_1) + b2$

$\sigma(x) = \frac{1}{1 + e^(-x)}$

We can implement more complex functions through simple, basic modules and repeated superposition

For more and more complex functions? How does the computer seek guidance?

1. What is machine learning?
2. The shortcomings of this method of KNN, what is the background of the proposed linear fitting
3. How to get faster function weight update through supervision method
4. The combination of nonlinear and linear functions can fit very complex functions
5. Deep learning we can fit more complex functions through basic function modules

### Assigment:

$L2-Loss(y, \hat{y}) = \frac{1}{n}\sum{(\hat{y} - y)}^2$

$L1-Loss(y, \hat{y}) = \frac{1}{n}\sum{|(\hat{y} - y)|}$

L2-Loss becomes L1Loss and achieves gradient descent

Realize L1Loss gradient descent from 0

#### 3. Data preprocessing

Normalization or standardization can prevent a certain dimension or a few dimensions from affecting the data too much when there are very many dimensions, and secondly, the program can run faster. There are many methods, such as standardization, min-max, z-score, p-norm, etc. How to use it depends on the characteristics of the data set.

Divide the data set, where 20% of the data is used as the test set X_test, y_test, and the other 80% are used as the training set X_train, y_train, where random_state is the random seed

Hivan Du

2021-08-31

2023-06-02