Econometrics/Spring 2018 / Reduction / Principal Component Analysis / Countries / PCA_countries.ipynb
2108 viewsKernel: Python 3 (old Anaconda 3)
In [1]:
In [2]:
Out[2]:
In [3]:
Out[3]:
<class 'pandas.core.frame.DataFrame'>
Index: 15 entries, Azerbaijan to Japan
Data columns (total 4 columns):
Average life expectancy 15 non-null object
Standard of living 15 non-null object
Percentage of urban population 15 non-null object
Daily caloric intake 15 non-null int64
dtypes: int64(1), object(3)
memory usage: 600.0+ bytes
In [4]:
In [5]:
Out[5]:
In [6]:
In [7]:
Out[7]:
<class 'pandas.core.frame.DataFrame'>
Index: 15 entries, Azerbaijan to Japan
Data columns (total 4 columns):
Average life expectancy 15 non-null float64
Standard of living 15 non-null float64
Percentage of urban population 15 non-null float64
Daily caloric intake 15 non-null int64
dtypes: float64(3), int64(1)
memory usage: 600.0+ bytes
In [8]:
In [10]:
Out[10]:
PCA(copy=True, iterated_power='auto', n_components=4, random_state=None,
svd_solver='auto', tol=0.0, whiten=False)
In [11]:
Out[11]:
[ 0.62895814 0.23681665 0.10712595 0.02709926]
In [12]:
Out[12]:
array([[ 0.09406675, -0.36847649],
[ 0.31480433, -1.3538389 ],
[-0.87043755, -0.40881141],
[-0.79088132, -0.48127669],
[ 0.75854797, 1.07668025],
[ 0.22782872, 1.58091451],
[-1.13671223, 1.36335547],
[-0.02385484, 0.43854101],
[-2.98560359, -0.13486692],
[-1.79548505, -1.17603596],
[-1.17550515, -0.21500811],
[ 1.20904754, 1.59854117],
[-0.04381248, -0.40575332],
[ 3.18493514, -0.1172517 ],
[ 3.03306177, -1.39671292]])
In [15]:
Out[15]:
In [16]:
Out[16]:
array([[ 0.84051867, -0.49769362],
[ 0.98831363, -0.09643122],
[ 0.86616025, 0.08066102],
[ 0.51192368, 0.86684737]])
In [18]:
Out[18]:
In [20]:
Out[20]:
array([[ 0.09406675],
[ 0.31480433],
[-0.87043755],
[-0.79088132],
[ 0.75854797],
[ 0.22782872],
[-1.13671223],
[-0.02385484],
[-2.98560359],
[-1.79548505],
[-1.17550515],
[ 1.20904754],
[-0.04381248],
[ 3.18493514],
[ 3.03306177]])
In [21]:
Out[21]:
array([ 0.62895814])
In [22]:
Out[22]:
array([[ 0.84051867],
[ 0.98831363],
[ 0.86616025],
[ 0.51192368]])
In [60]:
Out[60]:
[<matplotlib.lines.Line2D at 0xd817358>]
In [0]: