コード例 #1
0
def features_simple_modular(A=matrixA, B=matrixB, C=matrixC):

    a = RealFeatures(A)
    b = LongIntFeatures(B)
    c = ByteFeatures(C)

    # or 16bit wide ...
    #feat1 = f.ShortFeatures(N.zeros((10,5),N.short))
    #feat2 = f.WordFeatures(N.zeros((10,5),N.uint16))

    # print some statistics about a

    # get first feature vector and set it

    a.set_feature_vector(array([1, 4, 0, 0, 0, 9], dtype=float64), 0)

    # get matrices
    a_out = a.get_feature_matrix()
    b_out = b.get_feature_matrix()
    c_out = c.get_feature_matrix()

    assert (all(a_out == A))

    assert (all(b_out == B))

    assert (all(c_out == C))
    return a_out, b_out, c_out, a, b, c
コード例 #2
0
def features_simple_modular(A=matrixA,B=matrixB,C=matrixC):

    a=RealFeatures(A)
    b=LongIntFeatures(B)
    c=ByteFeatures(C)
    
# or 16bit wide ...
#feat1 = f.ShortFeatures(N.zeros((10,5),N.short))
#feat2 = f.WordFeatures(N.zeros((10,5),N.uint16))


# print some statistics about a

# get first feature vector and set it

    a.set_feature_vector(array([1,4,0,0,0,9], dtype=float64), 0)

# get matrices
    a_out = a.get_feature_matrix()
    b_out = b.get_feature_matrix()
    c_out = c.get_feature_matrix()

    assert(all(a_out==A))

    assert(all(b_out==B))

    assert(all(c_out==C))
    return a_out,b_out,c_out,a,b,c
コード例 #3
0
def kernel_linear_byte_modular(fm_train_byte=traindat,fm_test_byte=testdat):
	from shogun.Kernel import LinearKernel
	from shogun.Features import ByteFeatures

	feats_train=ByteFeatures(fm_train_byte)
	feats_test=ByteFeatures(fm_test_byte)

	kernel=LinearKernel(feats_train, feats_train)
	km_train=kernel.get_kernel_matrix()

	kernel.init(feats_train, feats_test)
	km_test=kernel.get_kernel_matrix()
	return kernel
コード例 #4
0
def features_simple_byte_modular(A):
	from shogun.Features import ByteFeatures

	# create dense features a
	# ... of type Byte
	a=ByteFeatures(A)

	# print some statistics about a
	#print a.get_num_vectors()
	#print a.get_num_features()

	# get first feature vector and set it
	#print a.get_feature_vector(0)
	a.set_feature_vector(numpy.array([1,4,0,0,0,9], dtype=numpy.uint8), 0)

	# get matrix
	a_out = a.get_feature_matrix()

	#print type(a_out), a_out.dtype
	#print a_out 
	assert(numpy.all(a_out==A))
	return a_out,a
コード例 #5
0
def features_simple_byte_modular(A):
    from shogun.Features import ByteFeatures

    # create dense features a
    # ... of type Byte
    a = ByteFeatures(A)

    # print some statistics about a
    #print a.get_num_vectors()
    #print a.get_num_features()

    # get first feature vector and set it
    #print a.get_feature_vector(0)
    a.set_feature_vector(numpy.array([1, 4, 0, 0, 0, 9], dtype=numpy.uint8), 0)

    # get matrix
    a_out = a.get_feature_matrix()

    #print type(a_out), a_out.dtype
    #print a_out
    assert (numpy.all(a_out == A))
    return a_out, a
コード例 #6
0
from shogun.Features import ByteFeatures
from numpy import array, uint8, all

# create dense matrix A
A=array([[1,2,3],[4,0,0],[0,0,0],[0,5,0],[0,0,6],[9,9,9]], dtype=uint8)

# ... of type Byte
a=ByteFeatures(A)


# print some statistics about a
print a.get_num_vectors()
print a.get_num_features()

# get first feature vector and set it
print a.get_feature_vector(0)
a.set_feature_vector(array([1,4,0,0,0,9], dtype=uint8), 0)

# get matrix
a_out = a.get_feature_matrix()

print type(a_out), a_out.dtype
print a_out 
assert(all(a_out==A))
コード例 #7
0
from shogun.Features import RealFeatures, LongIntFeatures, ByteFeatures
from numpy import array, float64, int64, uint8, all

# create dense matrices A,B,C
A=array([[1,2,3],[4,0,0],[0,0,0],[0,5,0],[0,0,6],[9,9,9]], dtype=float64)
B=array([[1,2,3],[4,0,0],[0,0,0],[0,5,0],[0,0,6],[9,9,9]], dtype=int64)
C=array([[1,2,3],[4,0,0],[0,0,0],[0,5,0],[0,0,6],[9,9,9]], dtype=uint8)

# ... of type Real, LongInt and Byte
a=RealFeatures(A)
b=LongIntFeatures(B)
c=ByteFeatures(C)

# or 16bit wide ...
#feat1 = f.ShortFeatures(N.zeros((10,5),N.short))
#feat2 = f.WordFeatures(N.zeros((10,5),N.uint16))


# print some statistics about a
print a.get_num_vectors()
print a.get_num_features()

# get first feature vector and set it
print a.get_feature_vector(0)
a.set_feature_vector(array([1,4,0,0,0,9], dtype=float64), 0)

# get matrices
a_out = a.get_feature_matrix()
b_out = b.get_feature_matrix()
c_out = c.get_feature_matrix()