예제 #1
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit_transform for float64 : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2)

try:
    emb = tsne.fit_transform(mat)
    print(desc, "Passed")
except:
    print(desc, "Failed")

FrovedisServer.shut_down()
예제 #2
0
desc = "Testing fit for DataFrame : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print ('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix([[0, 0, 0, 0], 
                 [0, 1, 1, 1], 
                 [1, 0, 1, 0],
                 [1, 1, 1, 0],
                 [1, 1, 1, 1]], 
                dtype=np.float64)
mat = pd.DataFrame(mat)
tsne = TSNE(n_components=2)

try:
    tsne.fit(mat)
    print(desc, "Passed")
except:
    print(desc, "Failed")

FrovedisServer.shut_down()

예제 #3
0
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing for accessing 'embedding_' attribute after calling fit() : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")'
          )
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, method='exact')

try:
    tsne.fit(mat)
    Y = tsne.embedding_
    print(desc, "Passed")
except:
    print(desc, "Failed")

FrovedisServer.shut_down()
예제 #4
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for n_iter>250 : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")'
          )
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, n_iter=251)

try:
    tsne.fit(mat)
    print(desc, "Passed")
except:
    print(desc, "Failed")

FrovedisServer.shut_down()
예제 #5
0
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for early_exaggeration=0 : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print ('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix([[0, 0, 0, 0], 
                 [0, 1, 1, 1], 
                 [1, 0, 1, 0],
                 [1, 1, 1, 0],
                 [1, 1, 1, 1]], 
                dtype=np.float64)
tsne = TSNE(n_components=2, early_exaggeration=0)

try:
    tsne.fit(mat)
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()

예제 #6
0
#!/usr/bin/env python

import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for metric='precomputed' with providing negative mat : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix([[0, -4, 9, 16], [9, 0, 4, 9], [1, 4, 0, -9], [9, 16, 25, 0]],
                dtype=np.float64)
tsne = TSNE(n_components=2, metric='precomputed')

try:
    tsne.fit(mat)
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()
예제 #7
0
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for metric='test' : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print ('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix([[0, 4, 9, 16], 
                 [9, 0, 4, 9], 
                 [1, 4, 0, 9],
                 [25, 4, 9, 0]],
                dtype=np.float64)
tsne = TSNE(n_components=2, metric='test')

try:
    tsne.fit(mat)
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()

예제 #8
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for method='barnes_hut': "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")'
          )
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, method='barnes_hut')

try:
    tsne.fit(mat)
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()
예제 #9
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for init='pca': "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, init='pca')

try:
    tsne.fit(mat)
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()
예제 #10
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing for setting 'n_iter_' attribute : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, method='exact')

try:
    tsne.n_iter_ = 500
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()
예제 #11
0
                #dtype=np.int64)
#mat = csr_matrix(mat)
#mat = csc_matrix(mat)
#mat = coo_matrix(mat)
#mat = FrovedisRowmajorMatrix(mat)
#mat = FrovedisColmajorMatrix(mat)  #Should raise an error
#mat = FrovedisCRSMatrix(mat)
#mat = pd.DataFrame(mat)
#mat = [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]]
#mat = ((0, 0, 0, 0), (0, 1, 1, 1), (1, 0, 1, 0), (1, 1, 1, 0), (1, 1, 1, 1))

print("input matrix: ")
print(mat) # for numpy matrix
#print(mat.debug_print()) # for row major matrix

tsne = TSNE().fit(mat)
print("embeddings_: ")
print(tsne.embedding_)
#print(tsne.embedding_.debug_print()) #for row major matrix

print("n_iter_: ")
print(tsne.n_iter_) 

print("kl_divergence_: ")
print(tsne.kl_divergence_)

# releasing results from server
#tsne.embedding_.release() #if mat is FrovedisRowmajorMatrix

# sample numpy dense data (3x3)
mat1 = np.matrix([[0, 0, 0, 0],
예제 #12
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for perplexity<0 : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, perplexity=-1)

try:
    tsne.fit(mat)
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()
예제 #13
0
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing for setting 'embedding_' attribute : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")'
          )
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
Y = np.matrix([[0, 0], [0, 1], [1, 0], [1, 1], [1, 1]], dtype=np.float64)
tsne = TSNE(n_components=2, method='exact')

try:
    tsne.embedding_ = Y
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()
예제 #14
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for metric='euclidean': "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")'
          )
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, metric='euclidean')

try:
    tsne.fit(mat)
    print(desc, "Passed")
except:
    print(desc, "Failed")

FrovedisServer.shut_down()
예제 #15
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for learning_rate>0 : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")'
          )
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, learning_rate=1.0)

try:
    tsne.fit(mat)
    print(desc, "Passed")
except:
    print(desc, "Failed")

FrovedisServer.shut_down()
예제 #16
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing fit for init='random': "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")')
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, init='random')

try:
    tsne.fit(mat)
    print(desc, "Passed")
except:
    print(desc, "Failed")

FrovedisServer.shut_down()
예제 #17
0
import sys
import numpy as np
from frovedis.exrpc.server import FrovedisServer
from frovedis.mllib.manifold import TSNE

desc = "Testing for setting 'kl_divergence_' attribute : "

# initializing the frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print('Please give frovedis_server calling command as the first argument\n\
           (e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")'
          )
    quit()
FrovedisServer.initialize(argvs[1])

# sample numpy dense data (3x3)
mat = np.matrix(
    [[0, 0, 0, 0], [0, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0], [1, 1, 1, 1]],
    dtype=np.float64)
tsne = TSNE(n_components=2, method='exact')

try:
    tsne.kl_divergence_ = 2.12
    print(desc, "Failed")
except:
    print(desc, "Passed")

FrovedisServer.shut_down()