[SOLVED] 代写 algorithm python statistic `

30 $

File Name: 代写_algorithm_python_statistic_`.zip
File Size: 329.7 KB

SKU: 0529409588 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


`
1. [20 marks] House data: This Assignment requires you to write a Python script for linear regression. You are not allowed to use any Python public libraries related to regression and metrics. You can compare the results of your program with sklearn, numpy, or scipy linear models, but the whole exercise is to write the algorithm yourself.
1.1 Load the House sales dataset from the houses.csv file and place them in a data-frame df. (Hint: You can
use pandas.read_csv function. New in pandas? Click here ). Then generate and show various statistic summary using pandas.DataFrame.describe method. What is pandas dataframe? Using pandas.DataFrame methods split the dataset into target value Y (price) and feature matrix X (all feature columns). In addition, extract the sqft_living column into a feature vector name X_1.
1.2 Write a function named linear_regression to implement Linear Regression without using public libraries related to regression. The inputs of this function should be predictor values (X or X_1), a target value (Y), a learning rate (lr), and the number of iterations (repetition). The function must build a linear model using gradient descent and output the model (params) and loss values per iteration (loss). Set the iteration to 10000 and calculate and show the mean squared error (MSE) for the models obtained from both X and X_1 predictors (hint: you might write another function named predict to predict the values based on X or X_1 and params) and plot the learning curve (loss) for both models in one figure (hint: use log scaling plot). Try different learning rates and show the results.
1.3 Visualize the best-obtained model for X_1 using a scatter plot to show price vs area and plot the linear model. Then, visualize the best-obtained model for all features (X) using a scatter plot to show the predicted vs actual target values.
1.4 Modify the linear_regression function in a way that applies Ridge regression, and name them linear_regression_Ridge. Then repeat the assignments 1.2 and 1.3. You can thereby use a fixed learning rate that you find appropriate, but you should try and plot different values for the regularization penalty alpha.
1.5 Use linear_regression_Ridge and write a function named linear_regression_Ridge_momentum in which you add a momentum term. Try different momenta and plot the learning curves with and without momentum for a fixed learning rate.
1.6 Modify the linear_regression_Ridge_momentum function in a way that it fits the feature vector X_1 with a polynomial of order 2 and name it as polynomial_regression_optimized. Calculate the MSE, plot the learning curve and show the quadratic model on the scatter plot (price vs area).
1

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 algorithm python statistic `
30 $