Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON PROGRAMMING filename = 'carpet_age.csv' URL = 'http://go.gwu.edu/engcomp1exam1' urlretrieve(URL, filename) age , cys_acid = numpy.loadtxt('carpet_age.csv', delimiter=',',skiprows=1, unpack=True) a) Using NumPy built-in functions, perform a linear

PYTHON PROGRAMMING

filename = 'carpet_age.csv' URL = 'http://go.gwu.edu/engcomp1exam1'

urlretrieve(URL, filename)

age , cys_acid = numpy.loadtxt('carpet_age.csv', delimiter=',',skiprows=1, unpack=True)

a) Using NumPy built-in functions, perform a linear regression on the data provided. Name the regression coefficients a1 and a0, and the fitting function returned by NumPy should be named age_lr.

Hint: in this case, the cysteic-acid content is the independent variable.

image text in transcribed

b) Plot the data and the linear regression curve on the same plot. Be sure to include:

  • Title
  • Label in the x-axis with units
  • Label in the y-axis with units
  • Legend for the linear regression

pyplot.rc('font', family='serif', size='16') # do not remove this line pyplot.figure(figsize=(10, 5)) # do not remove this line

c) c) Using the age_lr function obtained from linear regression, predict the age of two carpets that were measured to have cysteic-acid levels of 1.531.53 and 2.122.12, assign the predicted age to variables named carpet_ca153 and carpet_ca212 respectively.

image text in transcribed

Exercise 4 In this exercise, you will work with data to determine the age of old carpets by using chemical levels. The original work is 'Age Estimation of Old Carpets Based on Cystine and Cysteic Acid Content Source: J. Csapo, Z. Csapo-Kiss, T.G. Martin, S. Folestad, O. Orwar, A. Tivesten, and S. Nemethy (1995), "Age Estimation of Old Carpets Based on Cystine and Cysteic Acid Content," Analytica Chimica Acta, Vol. 300. pp. 313-320. We adapted the original data to extract only the columns that contain the age and the cysteic-acid content of the 23 samples provided, since the cysteic-acid content was the most accurate estimator according to the authors. The units are: [age : years [cys_acid] : (9 of amino acid / 100 g protein) During this exercise, you will estimate the age of two unknown carpets by using the measurements of the level of cysteic acid found on them. First, you will perform a linear regression on the known data and then you will use the regression function to predict the age of the two carpets. Let's start by importing the data into NumPy arrays, running the next two cells: In [ ]: Read a dataset filename = 'carpet_age.csv' URL = "http://go.gu.edu/engcomplexaml' urlretrieve (URL, filename) In [ ]: age, cys_acid - numpy.loadtxt('carpet_age.csv', delimiter-',,skiprows-1, unpack-True) a) Using NumPy built-in functions, perform a linear regression on the data provided. Name the regression coefficients al and all, and the fitting function returned by NumPy should be named age_lr. Hint in this case, the cysteic-acid content is the independent variable. In ( ) # YOUR CODE HERE raise Not ImplementedError() In 1: b) Plot the data and the linear regression curve on the same plot. Be sure to include: Title Label in the x-axis with units Label in the y-axis with units Legend for the linear regression In [ ]: pyplot.rc('font', family='serif', size='16') # do not remove this line pyplot.figure(figsize=(10, 5)) # do not remove this line # YOUR CODE HERE raise NotImplementedError() In [ ]: c) Using the age_lr function obtained from linear regression, predict the age of two carpets that were measured to have cysteic-acid levels of 1.53 and 2.12, assign the predicted age to variables named carpet_ca153 and carpet_ca212 respectively. In [ ]: # YOUR CODE HERE raise NotImplementedError() In [ ]: In [ ]: Exercise 4 In this exercise, you will work with data to determine the age of old carpets by using chemical levels. The original work is 'Age Estimation of Old Carpets Based on Cystine and Cysteic Acid Content Source: J. Csapo, Z. Csapo-Kiss, T.G. Martin, S. Folestad, O. Orwar, A. Tivesten, and S. Nemethy (1995), "Age Estimation of Old Carpets Based on Cystine and Cysteic Acid Content," Analytica Chimica Acta, Vol. 300. pp. 313-320. We adapted the original data to extract only the columns that contain the age and the cysteic-acid content of the 23 samples provided, since the cysteic-acid content was the most accurate estimator according to the authors. The units are: [age : years [cys_acid] : (9 of amino acid / 100 g protein) During this exercise, you will estimate the age of two unknown carpets by using the measurements of the level of cysteic acid found on them. First, you will perform a linear regression on the known data and then you will use the regression function to predict the age of the two carpets. Let's start by importing the data into NumPy arrays, running the next two cells: In [ ]: Read a dataset filename = 'carpet_age.csv' URL = "http://go.gu.edu/engcomplexaml' urlretrieve (URL, filename) In [ ]: age, cys_acid - numpy.loadtxt('carpet_age.csv', delimiter-',,skiprows-1, unpack-True) a) Using NumPy built-in functions, perform a linear regression on the data provided. Name the regression coefficients al and all, and the fitting function returned by NumPy should be named age_lr. Hint in this case, the cysteic-acid content is the independent variable. In ( ) # YOUR CODE HERE raise Not ImplementedError() In 1: b) Plot the data and the linear regression curve on the same plot. Be sure to include: Title Label in the x-axis with units Label in the y-axis with units Legend for the linear regression In [ ]: pyplot.rc('font', family='serif', size='16') # do not remove this line pyplot.figure(figsize=(10, 5)) # do not remove this line # YOUR CODE HERE raise NotImplementedError() In [ ]: c) Using the age_lr function obtained from linear regression, predict the age of two carpets that were measured to have cysteic-acid levels of 1.53 and 2.12, assign the predicted age to variables named carpet_ca153 and carpet_ca212 respectively. In [ ]: # YOUR CODE HERE raise NotImplementedError() In [ ]: In [ ]

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

Have issues been prioritized?

Answered: 1 week ago

Question

d. How will lack of trust be handled?

Answered: 1 week ago

Question

Are the rules readily available?

Answered: 1 week ago