Class: PCA::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/appswarm/routing/pca.rb

Instance Method Summary collapse

Constructor Details

#initialize(i = nil) ⇒ Input

Returns a new instance of Input.



12
13
14
15
16
17
18
19
# File 'lib/appswarm/routing/pca.rb', line 12

def initialize(i=nil)
  @vecs=[]
  if i
    if i.is_a?(Array)
      i.each{|k|self<<k}
    end
  end
end

Instance Method Details

#<<(v) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/appswarm/routing/pca.rb', line 20

def <<(v)
  assert {v.is_a?(Array)}
  if @vecs.length==0
    @vecs<<v
  else
    assert {@vecs[0].length == v.length }
    @vecs<<v
  end
end

#dmatrixObject



38
39
40
# File 'lib/appswarm/routing/pca.rb', line 38

def dmatrix
  Linalg::DMatrix[*@vecs]
end

#featureCountObject



34
35
36
# File 'lib/appswarm/routing/pca.rb', line 34

def featureCount
  @vecs[0].length
end

#trainCountObject



30
31
32
# File 'lib/appswarm/routing/pca.rb', line 30

def trainCount
  @vecs.length
end