Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON PROGRAMMING Using NumPy built-in functions, perform a linear regression on the data provided. Name the regression coefficients a1 and a0, and the fitting function

PYTHON PROGRAMMING

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.

age,cys_acid 120,0.88 128,1.03 170,1.19 250,1.21 140,1.22 300,1.32 400,1.49 400,1.53 550,1.87 1050,3.12 1400,3.54 1400,3.65 1400,3.72 1400,3.81 1550,3.82 1500,3.93 1550,3.97 1550,3.99 1600,4.01 1600,4.27 1600,4.3 1600,4.33 1750,4.39

image text in transcribedimage 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

Students also viewed these Databases questions