Hybrid recommendations simply select half recommendations from
        the ensemble recommender, and half from the curated one.

        Duplicate recommendations are accomodated by rank ordering
        by weight.
179710
def recommend(self, client_data, limit, extra_data={}):
        

        preinstalled_addon_ids = client_data.get("installed_addons", [])

        # Compute an extended limit by adding the length of
        # the list of any preinstalled addons.
        extended_limit = limit + len(preinstalled_addon_ids)

        ensemble_suggestions = self._ensemble_recommender.recommend(
            client_data, extended_limit, extra_data
        )
        curated_suggestions = self._curated_recommender.recommend(
            client_data, extended_limit, extra_data
        )

        # Generate a set of results from each of the composite
        # recommenders.  We select one item from each recommender
        # sequentially so that we do not bias one recommender over the
        # other.
        merged_results = set()

        while (
            len(merged_results) < limit
            and len(ensemble_suggestions) > 0
            and len(curated_suggestions) > 0
        ):

            r1 = ensemble_suggestions.pop()
            if r1[0] not in [temp[0] for temp in merged_results]:
                merged_results.add(r1)

            # Terminate early if we have an odd number for the limit
            if not (
                len(merged_results) < limit
                and len(ensemble_suggestions) > 0
                and len(curated_suggestions) > 0
            ):
                break

            r2 = curated_suggestions.pop()
            if r2[0] not in [temp[0] for temp in merged_results]:
                merged_results.add(r2)

        if len(merged_results) < limit:
            msg = (
                "Defaulting to empty results. Insufficient recommendations found for client: %s"
                % client_data["client_id"]
            )
            self.logger.info(msg)
            return []

        sorted_results = sorted(
            list(merged_results), key=op.itemgetter(1), reverse=True
        )

        log_data = (client_data["client_id"], str([r[0] for r in sorted_results]))

        self.logger.info(
            "Hybrid recommendations client_id: [%s], guids: [%s]" % log_data
        )
        return sorted_results
953600
function (item) {
            // Check if it already exists in the suggestions list.  Duplicates aren't allowed.
            var exists = false;
            for(var j = 0; j < suggestions.length; j++){
              if(suggestions[j].attr('name').toLowerCase() === item.name.toLowerCase()){
                exists=true;
                break;
              }
            }
            // If it didn't exist, add it to the list of suggestions and the searchTerms.
            if(!exists){
              suggestions.push(item);
            }

            // We are using searchTerms's setter to execute the filter, so have to set the property (not just update):
            var searchTerms = self.viewModel.attr('searchTerms').attr().concat(item.name);
            self.viewModel.attr('searchTerms', searchTerms);
          }
187185
private boolean selectACollection()
    {
        if (!cfm.comparator.hasCollections())
            return false;

        for (ColumnDefinition def : selection.getColumns())
        {
            if (def.type.isCollection() && def.type.isMultiCell())
                return true;
        }

        return false;
    }
975116
def hybrid_forward(self, F, x, sampled_values, label, weight, bias):
        """"""
        sampled_candidates, _, _ = sampled_values
        # (batch_size,)
        label = F.reshape(label, shape=(-1,))
        # (num_sampled+batch_size,)
        ids = F.concat(sampled_candidates, label, dim=0)
        # lookup weights and biases
        # (num_sampled+batch_size, dim)
        w_all = F.Embedding(data=ids, weight=weight,
                            input_dim=self._num_classes, output_dim=self._in_unit,
                            sparse_grad=self._sparse_grad)
        # (num_sampled+batch_size, 1)
        b_all = F.take(bias, indices=ids)
        return self._dense(x, sampled_values, label, w_all, b_all)
60243
def sia_bipartitions(nodes, node_labels=None):
    
    if config.CUT_ONE_APPROXIMATION:
        bipartitions = directed_bipartition_of_one(nodes)
    else:
        # Don't consider trivial partitions where one part is empty
        bipartitions = directed_bipartition(nodes, nontrivial=True)

    return [Cut(bipartition[0], bipartition[1], node_labels)
            for bipartition in bipartitions]
129775
def select(self, choice_scores):
        """"""
        # if we don't have enough scores to do K-selection, fall back to UCB1
        min_num_scores = min([len(s) for s in choice_scores.values()])
        if min_num_scores >= K_MIN:
            logger.info('{klass}: using Best K bandit selection'.format(klass=type(self).__name__))
            reward_func = self.compute_rewards
        else:
            logger.warning(
                '{klass}: Not enough choices to do K-selection; using plain UCB1'
                .format(klass=type(self).__name__))
            reward_func = super(RecentKReward, self).compute_rewards

        choice_rewards = {}
        for choice, scores in choice_scores.items():
            if choice not in self.choices:
                continue
            choice_rewards[choice] = reward_func(scores)

        return self.bandit(choice_rewards)
1114550
def _create_all_recommendations(cores, ip_views=False, config=None):
    """"""
    global _reco, _store

    _reco = GraphRecommender(_store)
    _reco.load_profile('Profiles')
    if ip_views:
        _reco.load_profile('Profiles_IP')

    manager = Manager()
    record_list = manager.list(_reco.all_records.keys())
    # record_list = manager.list(list(_reco.all_records.keys())[:10])
    num_records = len(_reco.all_records.keys())
    logger.info("Recommendations to build: {}".format(num_records))

    start = time.time()
    reco_version = config.get('recommendation_version', 0)
    done_records = num_records
    if cores <= 1:
        _create_recommendations(0, record_list, reco_version)
    else:
        try:
            pool = Pool(cores)
            multiple_results = [pool.apply_async(_create_recommendations,
                                (i, record_list, reco_version))
                                for i in range(cores)]
            # Wait for all processes to exit
            [res.get() for res in multiple_results]
        except KeyboardInterrupt:
            print("Caught KeyboardInterrupt, terminating workers")
            # TODO: Update done_records.
            pool.terminate()
            pool.join()

    duration = time.time() - start
    logger.info("Time {} for {} recommendations".format(duration,
                                                        done_records))
1194081
def clone(self, choices):
        
        return self.__class__(
            self.name,
            choices,
            self.label,
            self.description,
            self.multiple,
            self.viewFactory)
1305660
def create_all_recommendations(self, cores, ip_views=False):
        """"""
        global _store
        _store = self.store
        _create_all_recommendations(cores, ip_views, self.config)
1064052
public void setRecommendations(java.util.Collection<ReservationPurchaseRecommendation> recommendations) {
        if (recommendations == null) {
            this.recommendations = null;
            return;
        }

        this.recommendations = new java.util.ArrayList<ReservationPurchaseRecommendation>(recommendations);
    }
1242950
function (suggestions) {
                var selectedSuggestions = this.selectedSuggestions;
                var filteredSuggestions = [];
                for (var i = 0; i < suggestions.length; i++) {
                    var curSuggestion = suggestions[i];
                    if (this._findSuggestion(selectedSuggestions, curSuggestion) == -1) {
                        filteredSuggestions.push(curSuggestion);
                    }
                }
                return filteredSuggestions;
            }
439179
def uniq(items):
    
    acc = items[:1]
    for item in items[1:]:
        if item not in acc:
            acc += [item]

    return acc
1198362
def get_similar(obj, labels, default=None, min_similarity=0.5):
    
    raise NotImplementedError(
        "Unfinished implementation, needs to be in fuzzy_get where list of scores & keywords is sorted.")
    labels = listify(labels)

    def not_found(*args, **kwargs):
        return 0

    min_score = int(min_similarity * 100)
    for similarity_score in [100, 95, 90, 80, 70, 50, 30, 10, 5, 0]:
        if similarity_score <= min_score:
            similarity_score = min_score
        for label in labels:
            try:
                result = obj.get(label, not_found)
            except AttributeError:
                try:
                    result = obj.__getitem__(label)
                except (IndexError, TypeError):
                    result = not_found
            if result is not not_found:
                return result
        if similarity_score == min_score:
            if result is not not_found:
                return result
333424
def recommend(self, client_data, limit, extra_data={}):
        
        guids = self._curated_wl.get_randomized_guid_sample(limit)

        results = [(guid, 1.0) for guid in guids]

        log_data = (client_data["client_id"], str(guids))
        self.logger.info(
            "Curated recommendations client_id: [%s], guids: [%s]" % log_data
        )
        return results
894662
def _hybrid_select_metrics(self, dup_bam, bait_file, target_file):
        
        metrics = self._check_metrics_file(dup_bam, "hs_metrics")
        if not file_exists(metrics):
            with bed_to_interval(bait_file, dup_bam) as ready_bait:
                with bed_to_interval(target_file, dup_bam) as ready_target:
                    with file_transaction(metrics) as tx_metrics:
                        opts = [("BAIT_INTERVALS", ready_bait),
                                ("TARGET_INTERVALS", ready_target),
                                ("INPUT", dup_bam),
                                ("OUTPUT", tx_metrics)]
                        try:
                            self._picard.run("CollectHsMetrics", opts)
                        # HsMetrics fails regularly with memory errors
                        # so we catch and skip instead of aborting the
                        # full process
                        except subprocess.CalledProcessError:
                            return None
        return metrics
287786
def recommend(self, limit=10):
        '''
        
        '''
        expected_list = [(arm_id, beta_dist.expected_value()) for arm_id, beta_dist in self.__beta_dist_dict.items()]
        expected_list = sorted(expected_list, key=lambda x: x[1], reverse=True)
        return expected_list[:limit]
1323786
def error_check(options):
    

    compare = options.compare
    ensemble_paths = options.ensemble_paths

    if compare and len(ensemble_paths) > 2:
        print("\n Only 2 ensembles can be compared, {d} were specified\n".format(d=len(ensemble_paths)))
        sys.exit(1)