Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1- Sine and Cosine In this exercise, you will plot sine and cosine functions over the range of [-2, 2]. Put the plots

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Exercise 1- Sine and Cosine In this exercise, you will plot sine and cosine functions over the range of [-2, 2]. Put the plots of the two functions in one subplot. Your plot should have the following features: Set the color of cosine to be red and the color of sine to be blue. Set the line width for both to be 2.0. Set the line style to be -.' for cosine and -* for sine. Set the ticks for x-axis and y-axis such that the x-axis shows values [-2, -, O, , 2] and the y-axis shows values [-1, 0, 1]. Add the legend. Add labels for x-axis and y-axis to be x' and function values, respectively. Add a title for the plot (a title of your choice). Save the plot as 'sine_cosine.png' in your working directory. Your plot should be similar to the following: function values Sine and Cosine Functions W cosine sine -2m +2 Exercise 2 - Housing Price Background The real estate markets offer a compelling opportunity for data analysts to delve into the analysis and prediction of property prices. Such predictions have become increasingly crucial and advantageous. Property prices serve as a reliable indicator not only of the overall market condition but also the economic health of a country. The dataset provided here is a random sample extracted from a vast collection of property sales in the Seattle area in 2014. Features 1. price: the price of the estate 2. no_beds: number of bedrooms 3. no_baths: number of bathrooms 4. sqrt_living: square feet of living area (=sqft_above+ sqft_basement) 5. sqft lot: the square feet of the lot (land) owned 6. floors: number of floors 7. views: number of views 8. condition: the house condition (coded by 1-5, the larger number the poorer/older the 9. condition) 10. sqft above: the square feet of the area above the ground 11. sqft basement: the square feet of the basement 12. yr_built: the year in which the house is built 13. yr_renovated: the year in which the house is renovated 14. pop_density: population density near the location of the house Question 1 Use statsmodels to perform a simple statistical analysis on house price. Through the statistical analysis, we can gain insights into the variables that are related to (or correlated with) the focal variable (i.e., house price). a. Write down the dependent variable and independent variables that you are going to use for the regression model. b. What regression model do you choose and why? C. Obtain the summary of model estimation results. d. Based on your results, which variables are statistically significant at the 95% confidence interval? Note: write down your answers to the above questions as comments in your script file. Question 2 Now let's shift the angle to prediction. Suppose we aim to predict the housing price. As we mentioned in class, there are multiple methods that you may consider, such as linear regression, random forest, gradient boosting, or even deep-learning neural nets! In this exercise, let's try a simple linear regression approach. Suppose we are using the same set of independent variables as above. But this time, you need to split the data into training and test sets in order to get an appropriate assessment of model performance. a. Split the data into training and test with a ratio 75:25 (training 75% test 25%). b. Train a linear regression model using the training sets. c. Evaluate the model on the test set. d. As comments in your script, report the mean squared error (MSE) and the coefficient of determination (R2). Explain for each measure: (1) what it is, (2) how would you use it to assess model performance (HINT: think of a setting where you have multiple models to compare, how do you pick the best model?)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discovering Advanced Algebra An Investigative Approach

Authors: Jerald Murdock, Ellen Kamischke, Eric Kamischke

1st edition

1559539844, 978-1604400069, 1604400064, 978-1559539845

More Books

Students also viewed these Mathematics questions

Question

=+Describe the components of this time series.

Answered: 1 week ago