import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df=pd.read_csv('ex1data2.txt',header=None,
names=['siez of housing ','numbers of bedroom','house price'])
df.head()
|
siez of housing |
numbers of bedroom |
house price |
0 |
2104 |
3 |
399900 |
1 |
1600 |
3 |
329900 |
2 |
2400 |
3 |
369000 |
3 |
1416 |
2 |
232000 |
4 |
3000 |
4 |
539900 |
df=(df-df.mean())/df.std()
df.head()
|
siez of housing |
numbers of bedroom |
house price |
0 |
0.130010 |
-0.223675 |
0.475747 |
1 |
-0.504190 |
-0.223675 |
-0.084074 |
2 |
0.502476 |
-0.223675 |
0.228626 |
3 |
-0.735723 |
-1.537767 |
-0.867025 |
4 |
1.257476 |
1.090417 |
1.595389 |
X=df.iloc[:,0:2].values
X.shape
(47, 2)
X=np.insert(X,0,1,axis=1)
X=np