Page 150 - Data Science Algorithms in a Week
P. 150

Regression


                model = lm(celsius ~ fahrenheit, data = temperatures)
                print(model)

            Output:

                $ Rscript fahrenheit_celsius.r
                Call:
                lm(formula = celsius ~ fahrenheit, data = temperatures)
                Coefficients: (Intercept)     fahrenheit
                                 -17.7778         0.5556
            Therefore, we can see the following approximate linear dependence relation between C
            (degrees Celsius) and F (degrees Fahrenheit):

                                     C=fahrenheit*F+Intercept=0.5556*F-17.7778

            Note that this agrees with our previous calculation.

            Visualization:
            We display the linear model predicting degrees Celsius from degrees Fahrenheit
            underneath by a linear line. Its meaning is that the point (F,C) is on the green line if and
            only if F (degrees Fahrenheit) converts to C (degrees Celsius) and vice versa:


































                                                    [ 138 ]
   145   146   147   148   149   150   151   152   153   154   155