lundi 13 février 2017

Matrix inverse with Pandas dataframe

Vote count: 0

I am trying to run the following formula with a data frame and a series.

Let X be data frame with 3 columns. ( let it be a 100x3 matrix). Let y be a vector ( 100x1 matrix) X:

    X0  sqrfeet  bedrooms   
0   1     2104         3  
1   1     1600         3  
2   1     2400         3  
3   1     1416         2  
4   1     3000         4 

y:

0 20000
1 15000
2 24000
3 12000
4 14000

The formula I want to use is:- inv(X'*X)*X'*y

this is the formula for normal equation. Here X' implies X transpose and inv represents inverse. The code I had used is:-

var= (np.linalg.inv((X.T).dot(X)))
var2= var.dot(X.T)
final=var2.dot(Y)

Is the above correct?

Let X represents the real estate data with house size and number of bedrooms while Y corresponds to price.

asked 32 secs ago

Let's block ads! (Why?)



Matrix inverse with Pandas dataframe

Aucun commentaire:

Enregistrer un commentaire