Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python and scala help. Thank you thumps up will be given. SST means sum of squares total ( this turns out to be dot(y,y) where

Python and scala help. Thank you thumps up will be given.

SST means sum of squares total ( this turns out to be dot(y,y) where y is the centered vector (target variable) described below SSR means sum of squares of Regression , which is none other than : dot ( b * x, b* x) = b*b * dot(x,x) SSE means sum of error squares which is :dot ( y - b*x, y-b*x) And SST = SSR + SSE MSE = SSE/n where n =3 in this case RMSE ( root mean square ) = sqrt(MSE) correlation coefficient "r" = dot (x,y) /( norm(x) * norm(y) == cosine of the angle (radian measure) between these two vectors. where norm(v ) is the length of v, for any vector, in this case the length of centered vectors

***************** Here is the Exercise ******************************

Given a (feature)predictor vector, val X = Vector(3.0 ,4.0 , 5.0) and a target(l(label) variable val Y = Vector(6.0 , 9, 15) calculate all the parameters listed above..The vector entries need to be Doubles but it is sufficient to enter one Double in a vector and the compiler will cast all the other integer values to Doubles as well.

Here is how to do it, the algorithm (Estimator) steps..

1. Transform the X vector by subtracting off its mean ( 4 in this case) from each element, this is called the centered vector ( scaled) , call this val x = Vector( -1, 0, 1), and similarly, the Y vector when centered becomes: val y = Vector(-4, -1, 5)

The algorithm is: b = dot(x,y)/dot(x,x) // this is the dot product ( inner product) of two vectors) a = YBar = b * XBar where YBar is the mean of the original Y vector, while XBar is the mean of the original X vector Your task: is to calculate a, b and the additional parameters of this regression analysis, as noted below...

a. write the code that will calculate the mean of a vector. def mean(x: Vector[Double] = x.sum/x.size b. write the code that will center a vector c. write the function that will calculate the length of a vector. d. write the code that will calculate the dot product of two vectors ( this is a little advanced so I will give hints here. given two centered vectors x, y, then the dot product is: def dot(x: Vector[Double], y: Vector[ Double] = (x zip y). map{case( a,b) => a * b}.sum

Write the code to calc the other parameters.

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago