<s> from __future__ import division <EOL> import numpy as np <EOL> import scipy as sp <EOL> from scipy . io import loadmat <EOL> from dml . tool import pca , featurenormal , projectData , recoverData , displayData <EOL> import matplotlib . pyplot as plt <EOL> data = loadmat ( "<STR_LIT>" ) <EOL> X = data [ '<STR_LIT:X>' ] . transpose ( ) <EOL> plt . axis ( [ <NUM_LIT:0> , <NUM_LIT:8> , <NUM_LIT:0> , <NUM_LIT:8> ] ) <EOL> '''<STR_LIT>''' <EOL> X_norm , mu , sigma = featurenormal ( X ) <EOL> plt . plot ( X [ <NUM_LIT:0> , : ] , X [ <NUM_LIT:1> , : ] , '<STR_LIT:o>' ) <EOL> U , S = pca ( X_norm ) <EOL> tt = mu + U [ : , <NUM_LIT:0> ] <EOL> tp = mu + U [ : , <NUM_LIT:1> ] <EOL> plt . plot ( [ mu [ <NUM_LIT:0> ] , tt [ <NUM_LIT:0> ] ] , [ mu [ <NUM_LIT:1> ] , tt [ <NUM_LIT:1> ] ] ) <EOL> plt . plot ( [ mu [ <NUM_LIT:0> ] , tp [ <NUM_LIT:0> ] ] , [ mu [ <NUM_LIT:1> ] , tp [ <NUM_LIT:1> ] ] ) <EOL> plt . show ( ) <EOL> plt . axis ( [ - <NUM_LIT:3> , <NUM_LIT:3> , - <NUM_LIT:3> , <NUM_LIT:3> ] ) <EOL> plt . plot ( X_norm [ <NUM_LIT:0> , : ] , X_norm [ <NUM_LIT:1> , : ] , '<STR_LIT:o>' ) <EOL> Z = projectData ( X_norm , U , <NUM_LIT:1> ) ; <EOL> X_rec = recoverData ( Z , U , <NUM_LIT:1> ) ; <EOL> plt . plot ( X_rec [ <NUM_LIT:0> , : ] , X_rec [ <NUM_LIT:1> , : ] , '<STR_LIT:o>' ) <EOL> for i in range ( X . shape [ <NUM_LIT:1> ] ) : <EOL> plt . plot ( [ X_norm [ <NUM_LIT:0> , i ] , X_rec [ <NUM_LIT:0> , i ] ] , [ X_norm [ <NUM_LIT:1> , i ] , X_rec [ <NUM_LIT:1> , i ] ] , '<STR_LIT:r>' ) <EOL> plt . show ( ) <EOL> '''<STR_LIT>''' <EOL> data = loadmat ( "<STR_LIT>" ) <EOL> X = data [ '<STR_LIT:X>' ] . transpose ( ) <EOL> X_norm , mu , sigma = featurenormal ( X ) <EOL> fig = plt . figure ( ) <EOL> fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ) <EOL> plt . imshow ( displayData ( X_norm [ : , : <NUM_LIT:100> ] ) , cmap = '<STR_LIT>' ) <EOL> [ U , S ] = pca ( X_norm ) ; <EOL> print S <EOL> K = <NUM_LIT:100> ; <EOL> Z = projectData ( X_norm , U , K ) ; <EOL> X_rec = recoverData ( Z , U , K ) ; <EOL> fig . add_subplot ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> plt . imshow ( displayData ( X_rec [ : , : <NUM_LIT:100> ] ) , cmap = '<STR_LIT>' ) <EOL> plt . show ( ) </s>
