Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do the following project in Racket language. #lang racket (provide (all-defined-out)) ;; for us to test (require racket/trace) ii in case you want to use

Do the following project in Racket language.

image text in transcribed

image text in transcribed

#lang racket (provide (all-defined-out)) ;; for us to test (require racket/trace) ii in case you want to use tracing (require "PTS.rkt") ; to access the database of points You are only allowed to use functions, if-then-else, cond, list operations, operations on numbers. No imperative-style constructs, such as begin-end or explicitly variable assignments, such as get/set are allowed. If you do not follow the guidelines, your submission will not be graded. If you are in doubt that you are using some construct that may violate rules, please contact instructor/TA (post on Piazza). 2. We have applied least squares method for regression analysis in the previous question. However, this method may not be suitable for situation, where the number of dependent variables is greater than one. A general technique is based on iteratively refining m and c, starting from some approximate solutions (e.g., 0 for both m and c), with the objective of reducing the E. The iterative refinement takes into consideration three parameters that decide the termination condi- tion: the learning rate L, the error-margine and the maximum number of times the refinement can be performed cnt. Intuitively, L describes the degree of refinement in each step and e describes the closeness of the refined result to the expected result. The steps of the iterative refinement method is as follows: (a) Initialize m and c both to 0.0. (b) if E (as per Equation 1) is less than e (error margin) or the number of iteration already performed is greater than equal to cnt, then terminate. The current values of m and care used to describe the regression line. (c) Otherwise, i. update the value of m to m-L x , where de 3 i 4 ) ii. update the value of c to c-L x , where -2 = n (gi - 9) (d) Repeat from step (b). This technique is called gradient descent. Write a function gradient_mc that takes as argument the list of points, the parameters correspond- ing to L and e, and the parameter cnt corresponding to the maximum number of times the iterative refinement can be performed, and returns a list containing three elements: the first element is the valuation of m, the second that of c, and the third element is corresponding the valuations of m and c. The function implements gradient descent iterative technique as described above. For example for the same set of points pt sl, pts2, pts3, > (gradient_mc pts1 0.001 0.01 5000) (-0.01504233062 8280118 1.4188766008006697 1.8384651009912811) > (gradient_mc pts2 0.001 0.01 5000) (0.9222504727270914 0.16598399730907806 0.009992616854817024) > (gradient_mc pts3 0.001 0.01 5000) (0.908583804857839 -0.7312252383800322 0.012064947703199078) #lang racket (provide (all-defined-out)) ;; for us to test (require racket/trace) ii in case you want to use tracing (require "PTS.rkt") ; to access the database of points You are only allowed to use functions, if-then-else, cond, list operations, operations on numbers. No imperative-style constructs, such as begin-end or explicitly variable assignments, such as get/set are allowed. If you do not follow the guidelines, your submission will not be graded. If you are in doubt that you are using some construct that may violate rules, please contact instructor/TA (post on Piazza). 2. We have applied least squares method for regression analysis in the previous question. However, this method may not be suitable for situation, where the number of dependent variables is greater than one. A general technique is based on iteratively refining m and c, starting from some approximate solutions (e.g., 0 for both m and c), with the objective of reducing the E. The iterative refinement takes into consideration three parameters that decide the termination condi- tion: the learning rate L, the error-margine and the maximum number of times the refinement can be performed cnt. Intuitively, L describes the degree of refinement in each step and e describes the closeness of the refined result to the expected result. The steps of the iterative refinement method is as follows: (a) Initialize m and c both to 0.0. (b) if E (as per Equation 1) is less than e (error margin) or the number of iteration already performed is greater than equal to cnt, then terminate. The current values of m and care used to describe the regression line. (c) Otherwise, i. update the value of m to m-L x , where de 3 i 4 ) ii. update the value of c to c-L x , where -2 = n (gi - 9) (d) Repeat from step (b). This technique is called gradient descent. Write a function gradient_mc that takes as argument the list of points, the parameters correspond- ing to L and e, and the parameter cnt corresponding to the maximum number of times the iterative refinement can be performed, and returns a list containing three elements: the first element is the valuation of m, the second that of c, and the third element is corresponding the valuations of m and c. The function implements gradient descent iterative technique as described above. For example for the same set of points pt sl, pts2, pts3, > (gradient_mc pts1 0.001 0.01 5000) (-0.01504233062 8280118 1.4188766008006697 1.8384651009912811) > (gradient_mc pts2 0.001 0.01 5000) (0.9222504727270914 0.16598399730907806 0.009992616854817024) > (gradient_mc pts3 0.001 0.01 5000) (0.908583804857839 -0.7312252383800322 0.012064947703199078)

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

A Complete Guide To Data Science Essentials

Authors: Miguel

1st Edition

9358684992, 978-9358684995

More Books

Students also viewed these Databases questions