Write two object classes and helper function to read in text

Assignment Help Applied Statistics
Reference no: EM131745415

Final Project

Instructions:

In this project, you will write two object classes and a helper function to read in text data.

Three Python files have been provided for you to complete:

  • data.py
  • linear_regression.py
  • read_data.py

You will need to edit these files and push them to your ncsu repo:

  • You may work together, but you must list all collaborators in your read_data.py file.
  • Please no copy and pasting among collaborators. You'll learn better if you discuss and write your code on your own.
  • If you use, online or other resources, also list them in your read_data.py file.

Part I: Reading data into two lists. Edit the file read_data.py

1. In the file read_data.py, define a function read_data that takes in a string called input_file_name that contains a path to an input file. Assume that the input file path contains two floating point number per line separated by spaces. Your function should return two lists whose elements are those floating point numbers contained in the input file.

Part II: Data class and methods. Edit the file data.py

2. Write a Data class with an __init__ method that takes two lists of numbers as parameters and stores them in two attributes x and y.

3. Write a Data method called num_obs that takes in no parameters and outputs the number of observations in the data, i.e. the length of its attribute x (or y since they should be the same.).

4. Write a __str__ method that returns a string that gives the following format when printed.

>>> dat = Data([1,2,3],[2,4,6])

>>> print(dat)

x              y

1              2

2              4

3              6

5. Write a Data method called compute_sample_means that returns sample mean of the attributes x and sample mean of the attributes y, as a tuple of numbers.

6. Write a Data method called compute_least_squares_fit that returns the intercept and slope of the simple linear regression ?t of the data.

Hint: First compute the quantities Sxy and Sxx. Then compute the slope β1 and then finally compute the intercept β0.

7. Write a Data method called compute_SST that returns the sum of squares total (SST) of the attribute y.

Part III: SLR class and methods. Edit the file linear_regression.py

8. Write the SLR class with an __init__ method that takes in a Data object as a parameter. The __init__ method should store the contents of the parameter in an attribute called data. It should also compute the intercept β0 and slope β1 and store theses values in the attributes beta0 and beta1, respectively.

9. Write the SLR method predict that takes a new x_new value as a parameter and predicts a new y_new value.

10. Write the SLR method compute_residuals that returns the residuals of the SLR object in a list of numbers.

11. Write the SLR method compute_SSResid that returns the sum of square residuals (SSResid).

12. Write the SLR method compute_residual_sd that returns the residual standard deviation.

13. Write the SLR method compute_rsquared that returns the R-squared of the SLR fit.

14. Write a __str__ method that returns a string that gives the following format when printed (Note the number of decimal digits!).

>>> filename = 'bmi_vs_sbp.txt'

>>> x, y = read_data(filename)

>>> dat = Data(x,y)

>>> lm = SLR(dat)

>>> print(lm)

Least squares fit on 10 data points.

Intercept = 45.584331

Slope = 3.465523

Residual standard deviation = 13.051139

R-squared = 0.731364

Attachment:- Assignment Files.rar

Reference no: EM131745415

Questions Cloud

Discuss about the athletes and gambling : Athletes and gambling. A survey of student athletes that asked questions about gambling behavior classified students according to the National Collegiate.
Impact of the miranda decision on law enforcement : Was the Court’s decision a wise one and what has been the impact of the Miranda decision on law enforcement?
Evaluate any gaps in the knowledge and skills assessed : Evaluate any gaps in the knowledge and skills assessed. Compare the form to the different techniques used to measure leadership effectiveness.
Companies need to consider when sourcing product : What factors do companies need to consider when sourcing product?
Write two object classes and helper function to read in text : ST114: Final Project. Instructions: In this project, you will write two object classes and a helper function to read in text data
Calculate the cycle service level : The team has been tasked with the development of an ethics training program to support the company’s new code of ethics. Calculate the cycle service level.
What are the cultural influences on training and development : What are the cultural influences on training and development? Provide two examples. How do internal and external social media influence organizational culture?
Discuss a households consumption and labor supply decisions : What impact would you expect increases and decreases in house value to have on the consumption behavior of house owners
Describe how trade deficits or surpluses can influence gdp : Develop an understanding of what money is, what forms money takes, how the banking system helps create money, and how the Federal Reserve controls the quantity

Reviews

Write a Review

Applied Statistics Questions & Answers

  Hypothesis testing

What assumptions about the number of pedestrians passing the location in an hour are necessary for your hypothesis test to be valid?

  Calculate the maximum reduction in the standard deviation

Calculate the maximum reduction in the standard deviation

  Calculate the expected value, variance, and standard deviati

Calculate the expected value, variance, and standard deviation of the total income

  Determine the impact of social media use on student learning

Research paper examines determine the impact of social media use on student learning.

  Unemployment survey

Find a statistics study on Unemployment and explain the five-step process of the study.

  Statistical studies

Locate the original poll, summarize the poling procedure (background on how information was gathered), the sample surveyed.

  Evaluate the expected value of the total number of sales

Evaluate the expected value of the total number of sales

  Statistic project

Identify sample, population, sampling frame (if applicable), and response rate (if applicable). Describe sampling technique (if applicable) or experimental design

  Simple data analysis and comparison

Write a report on simple data analysis and comparison.

  Analyze the processed data in statistical survey

Analyze the processed data in Statistical survey.

  What is the probability

Find the probability of given case.

  Frequency distribution

Accepting Manipulation or Manipulating

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd