Skip to content

Commit

Permalink
scaling: z-score
Browse files Browse the repository at this point in the history
  • Loading branch information
orbxball committed Apr 1, 2017
1 parent 10eb01a commit b673154
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hw2/generative.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ def halfGaussianDistribution(mean, cov, x):
X_test = pd.read_csv(X_test).as_matrix() #shape: (16281, 106)
Y_train = Y_train.reshape(Y_train.shape[0]) #shape: (32561,)

# scaling: only on features, not label
mean = np.mean(X_train, axis=0) #shape: (106,)
std = np.std(X_train, axis=0) #shape: (106,)
X_train = (X_train - mean) / (std + 1e-100)
X_test = (X_test - mean) / (std + 1e-100)

# Seperate class A(1) & class B(0)
Apicker = (Y_train == 1)
Bpicker = (Y_train == 0)
Expand Down

0 comments on commit b673154

Please sign in to comment.