Esempio n. 1
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')
    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")
except:
    print("Passed")

FrovedisServer.shut_down()
Esempio n. 2
0
# prediction on created model
print("predicting on factorization machine classifier model: ")
print(fmc.predict(cmat))

# saving the model
fmc.save("./out/FMCModel")

mat2 = np.random.randint(5, size=(8, 50))
mat2 = np.asmatrix(mat2, dtype=np.float64)
cmat2 = FrovedisCRSMatrix(mat2, dtype=np.float64)
lbl2 = np.array([1.2, 0.3, 1.1, 1.9, 1.7, 0.5, 1.2, 1.1], dtype=np.float64)
# fitting input matrix and label on Factorization Machine Regressor object
fmr = FactorizationMachineRegressor(iteration=100,
                                    init_stdev=0.1,
                                    init_learn_rate=0.01,
                                    optimizer="SGD",
                                    dim=(True, True, 8),
                                    reg=(False, False, 0),
                                    batch_size_pernode=5000,
                                    verbose=0).fit(cmat2, lbl2)

# prediction on created model
print("predicting on factorization machine regressor model: ")
print(fmr.predict(cmat2))

# saving the model
fmr.save("./out/FMRModel")

# clean-up
fmc.release()
fmr.release()
FrovedisServer.shut_down()