def build_sparse_matrix_target(limit=0): targets_vector = DataDAO.get_targets() targets_matrix = [] for ind, item in enumerate(targets_vector): if limit != 0 and ind >= limit: break multiclass_vector = TrainingFactory.get_category_vector(item) targets_matrix.append(multiclass_vector) sparse = csr_matrix(targets_matrix) return sparse
def build_target_vector_by_category(category, limit=0): targets_vector = DataDAO.get_targets() targets_cat = [] for ind, item in enumerate(targets_vector): if limit != 0 and ind >= limit: break if item == category: targets_cat.append(1) else: targets_cat.append(0) return targets_cat