Evaluation of a model using Python brew package -
i have read document using classification models in python using brew package. based on original example, can create ensemble following code:
from brew.selection.dynamic.lca import lca brew.generation.bagging import bagging brew.base import ensembleclassifier sklearn.tree import decisiontreeclassifier import numpy np x = np.array([[-1, 0], [-0.8, 1], [-0.8, -1], [-0.5, 0], [0.5, 0], [1, 0], [0.8, 1], [0.8, -1]]) y = np.array([1, 1, 1, 2, 1, 2, 2, 2]) tree = decisiontreeclassifier(max_depth=1, min_samples_leaf=1) bag = bagging(base_classifier=tree, n_classifiers=10) bag.fit(x, y) lca = lca(x, y, k=3) clf = ensembleclassifier(bag.ensemble, selector=lca) based on brew documents, can evaluate model within function:
def acc_score(y_true, y_pred, positive_label=1): if hasattr(sklearn.metrics, 'accuracy_score'): return sklearn.metrics.accuracy_score(y_true, y_pred) return float(np.sum(y_true == y_pred)) / y_true.shape[0] can me in order evaluate model within 'acc_score' function?
Comments
Post a Comment