Exemplo n.º 1
0
seed = 0
Xtrain, ytrain, Xtest, ytest = covtype(train_size=4000000, seed=seed)
covtype_size = [
    100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000,
    1000000
]

new_arr = np.repeat(Xtrain, 3, axis=0)  #increase dataset size

print(len(new_arr))
total_time = []
#nr_tree = 32 #Change to run script for different number of trees

file_name = './models/model_' + str(nr_tree) + 'tree_4jobs.data'
model = WoodClassifier.load(file_name)
nr_classes = len(np.unique(ytrain)) + 1
model.compile_store_v2(new_arr, nr_classes, 10)

print("Number of estimators: \t\t%i" % model.n_estimators)
forest_time = []

for i in xrange(len(covtype_size)):
    times = np.zeros(8, np.float32)
    X_temp = new_arr[:covtype_size[i]]
    print("Number of training patterns:\t%i" % X_temp.shape[0])

    start_time = time.time()
    cpu_test = model.predict(X_temp)
    cpu_test = model.predict(X_temp)
    cpu_test = model.predict(X_temp)
Exemplo n.º 2
0
from sklearn.metrics import accuracy_score

from woody import WoodClassifier
from woody.data import *

seed = 0

#Xtrain, ytrain, Xtest, ytest = covtype(train_size=400000, seed=seed)
Xtrain, ytrain, Xtest, ytest = susy(train_size=4000000, seed=seed)
if Xtrain.dtype != np.float32:
    Xtrain = Xtrain.astype(np.float32)
    ytrain = ytrain.astype(np.float32)
    Xtest = Xtest.astype(np.float32)
    ytest = ytest.astype(np.float32)

model = WoodClassifier.load('./model_susy8tree.data')
nr_classes = len(np.unique(ytrain)) + 1  #not sure if accurate
model.compile_and_Store(Xtrain, nr_classes)

cpu_train = model.predict(Xtrain)
cpu_test = model.predict(Xtest)
#print(cpu_train)

assert np.allclose(
    cpu_train,
    model.cuda_predict(Xtrain)) == True, "cuda_predict failed for train set"
assert np.allclose(cpu_train, model.cuda_pred_tree_mult(
    Xtrain, 10)) == True, "cuda_pred_tree_mult failed for train set"
assert np.allclose(cpu_train, model.cuda_pred_forest(
    Xtrain)) == True, "cuda_pred_forest failed for train set"
assert np.allclose(cpu_train, model.cuda_pred_forest_mult(