Ejemplo n.º 1
0
# Description: setting number of retained components and variance covered, using generalized eigenvectors
# Category:    projection
# Uses:        iris
# Referenced:  orngPCA.htm
# Classes:     orngPCA.PCA

import orange, orngPCA

data = orange.ExampleTable("iris.tab")

attributes = ['sepal length', 'sepal width', 'petal length', 'petal width']
pca = orngPCA.PCA(data,
                  standardize=True,
                  attributes=attributes,
                  maxNumberOfComponents=-1,
                  varianceCovered=1.0)
print "Retain all vectors and full variance:"
print pca

pca = orngPCA.PCA(data,
                  standardize=True,
                  maxNumberOfComponents=-1,
                  varianceCovered=1.0,
                  useGeneralizedVectors=1)
print "As above, only with generalized vectors:"
print pca
Ejemplo n.º 2
0
# Description: projecting data with trained PCA
# Category:    projection
# Uses:        iris
# Referenced:  orngPCA.htm
# Classes:     orngPCA.PCA

import orange, orngPCA

data = orange.ExampleTable("iris.tab")

attributes = ['sepal length', 'sepal width', 'petal length', 'petal width']
pca = orngPCA.PCA(data, attributes=attributes, standardize=True)

projected = pca(data)
print "Projection on first two components:"
for d in projected[:5]:
    print d
Ejemplo n.º 3
0
# Description: PCA with attribute and row selection
# Category:    projection
# Uses:        iris
# Referenced:  orngPCA.htm
# Classes:     orngPCA.PCA

import orange, orngPCA

data = orange.ExampleTable("iris.tab")

pca = orngPCA.PCA(data, standardize=True)
print "PCA on all data:"
print pca

attributes = ['sepal length', 'sepal width', 'petal length', 'petal width']
pca = orngPCA.PCA(data, standardize=True, attributes=attributes)
print "PCA on attributes sepal.length, sepal.width, petal.length, petal.width:"
print pca

rows = [1, 0] * (len(data) / 2)
pca = orngPCA.PCA(data, standardize=True, rows=rows)
print "PCA on every second row:"
print pca
Ejemplo n.º 4
0
# Description: using your own imputer and continuizer in PCA
# Category:    projection
# Uses:        adult_sample
# Referenced:  orngPCA.htm
# Classes:     orngPCA.PCA

import orange, orngPCA

data = orange.ExampleTable("bridges.tab")

imputer = orange.ImputerConstructor_maximal

continuizer = orange.DomainContinuizer()
continuizer.multinomialTreatment = continuizer.AsNormalizedOrdinal
continuizer.classTreatment = continuizer.Ignore
continuizer.continuousTreatment = continuizer.Leave

pca = orngPCA.PCA(data,
                  standardize=True,
                  imputer=imputer,
                  continuizer=continuizer)
print pca