Ejemplo n.º 1
0
from frovedis.matrix.crs import FrovedisCRSMatrix
from frovedis.mllib.fm import FactorizationMachineRegressor
from frovedis.matrix.dvector import FrovedisDoubleDvector

#obj: passing negative barch size per node
# 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')
    quit()
FrovedisServer.initialize(argvs[1])

mat = FrovedisCRSMatrix(dtype=np.float64).load("./input/classification.txt")
lbl = FrovedisDoubleDvector([3, 4, 3, 3, 4, 1, 5, 2, 5, 5])

# fitting input matrix and label on Factorization Machine Classifier object

fm_obj = FactorizationMachineRegressor(iteration=10,
                                       init_stdev=0.1,
                                       init_learn_rate=0.1,
                                       optimizer="SGD",
                                       dim=(True, True, 8),
                                       reg=(0., 0., 0),
                                       batch_size_pernode=-1,
                                       verbose=0)

try:
    model = fm_obj.fit(mat, lbl)
    print("Failed")
Ejemplo n.º 2
0
from frovedis.exrpc.server import FrovedisServer
from frovedis.matrix.sparse import FrovedisCRSMatrix
from frovedis.matrix.dvector import FrovedisDoubleDvector
from frovedis.mllib.svm import LinearSVC
import sys

# 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])

mat = FrovedisCRSMatrix().load("./input/libSVMFile.txt")
lbl = FrovedisDoubleDvector([1,0,1,1,1,0,1,1])

# fitting input matrix and label on linear svm object
svm = LinearSVC(solver='lbfgs',verbose=0).fit(mat,lbl)

# predicting on loaded model
print("predicting on lbfgs svm regression model: ")
print svm.predict(mat)

# fitting input matrix and label on linear svm object
svm = LinearSVC(solver='sag',verbose=0).fit(mat,lbl)

# predicting on loaded model
print("predicting on sgd svm regression model: ")
print svm.predict(mat)
Ejemplo n.º 3
0
from frovedis.exrpc.server import FrovedisServer
from frovedis.matrix.sparse import FrovedisCRSMatrix
from frovedis.matrix.dvector import FrovedisDoubleDvector
from frovedis.mllib.linear_model import *
import sys

# 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])

mat = FrovedisCRSMatrix().load("./input/libSVMFile.txt")
lbl = FrovedisDoubleDvector([1.1, 0.2, 1.3, 1.4, 1.5, 0.6, 1.7, 1.8])

# fitting input matrix and label on linear regression object
lr = LinearRegression(solver='lbfgs', verbose=0).fit(mat, lbl)

# predicting on loaded model
print("predicting on lbfgs linear regression model: ")
print lr.predict(mat)

# fitting input matrix and label on linear regression object
lr = LinearRegression(solver='sag', verbose=0).fit(mat, lbl)

# predicting on loaded model
print("predicting on sag linear regression model: ")
print lr.predict(mat)