Module: PCA

Defined in:
lib/appswarm/routing/pca.rb

Defined Under Namespace

Classes: Base, Input

Instance Method Summary collapse

Instance Method Details

#doOrthoPCAObject



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/appswarm/routing/pca.rb', line 137

def doOrthoPCA

trainCount=@input.trainCount
featureCount=@input.featureCount

#[email protected]
d=@input.dmatrix
@middle=d.middle_row
dt=d.transpose

t=d*dt

t=t*(1.0/trainCount)

eigenValues=eigenVectors=nil
t.eigensystem {|_eigenVectors,_eigenValues,img|
  eigenValues=_eigenValues
  eigenVectors=_eigenVectors
}

nvr=dT*eigenVectors

#Tools::Math::Matrix nvr(trainCount,featureCount);

#nvr=dT*vr;


#  PCAOutput o;



#  for(size_t y=0;y<ev.size();y++)
#    {
#      PCAVector v;
#      double scale;

#      if(ev[y]>0)
#  scale=sqrt(ev[y]*trainCount);
#      else
#  scale=0;

#      if(scale<=0.0f)
#  scale=0;
#      else
#  scale=1.0/scale;


#      for(size_t x=0;x<nvr.nrows();x++)
#  v.push_back(nvr(x,y)*scale);
#      o.vectors.push_back(v);
#      o.values.push_back(ev[y]>0?ev[y]:0);
#    }
end