Set anomaly scores using a weighted sum.
979611
def _set_scores(self):
        
        anom_scores_ema = self.exp_avg_detector.run()
        anom_scores_deri = self.derivative_detector.run()
        anom_scores = {}
        for timestamp in anom_scores_ema.timestamps:
            # Compute a weighted anomaly score.
            anom_scores[timestamp] = max(anom_scores_ema[timestamp],
                                         anom_scores_ema[timestamp] * DEFAULT_DETECTOR_EMA_WEIGHT + anom_scores_deri[timestamp] * (1 - DEFAULT_DETECTOR_EMA_WEIGHT))
            # If ema score is significant enough, take the bigger one of the weighted score and deri score.
            if anom_scores_ema[timestamp] > DEFAULT_DETECTOR_EMA_SIGNIFICANT:
                anom_scores[timestamp] = max(anom_scores[timestamp], anom_scores_deri[timestamp])
        self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))
544088
def generate_anomaly(self, input_word, list_of_dict_words, num):
        

        results = []
        for i in range(0,num):
            index = randint(0,len(list_of_dict_words)-1)
            name = list_of_dict_words[index]
            if name != input_word and name not in results:
                results.append(PataLib().strip_underscore(name))
            else:
                i = i +1
        results = {'input' : input_word, 'results' : results, 'category' : 'anomaly'} 
        return results
741401
def set_stats(stats, value):
    
    stats["total_count"] += 1
    stats["value"] += value
    stats["average"] = stats["value"] / stats["total_count"]

    # this is just a basic example and not the best way to track aggregation.
    # for max and min old there are cases where this will not work correctly.
    if value > stats["max"]:
        stats["max"] = value

    if value < stats["min"] or stats["min"] == 0:
        stats["min"] = value
246587
def set_sum_w2(self, w, ix, iy=0, iz=0):
        
        if self.GetSumw2N() == 0:
            raise RuntimeError(
                "Attempting to access Sumw2 in histogram "
                "where weights were not stored")
        xl = self.nbins(axis=0, overflow=True)
        yl = self.nbins(axis=1, overflow=True)
        idx = xl * yl * iz + xl * iy + ix
        if not 0 <= idx < self.GetSumw2N():
            raise IndexError("bin index out of range")
        self.GetSumw2().SetAt(w, idx)
119546
def weighted_choice(self, probabilities, key):
        """"""

        total = sum(x[0] for x in probabilities)
        choice = total * self._random(key)

        for probability, option in probabilities:
            choice -= probability
            if choice <= 0:
                return option
556863
def set_features(self):
        """"""
        self.scores = {}
        for t_or_d, feats in zip(['target', 'decoy'], [self.target,
                                                       self.decoy]):
            self.scores[t_or_d] = {}
            self.scores[t_or_d]['scores'] = self.score_get_fun(
                feats, self.featuretype, self.prepare_percolator_output)
            self.scores[t_or_d]['fn'] = '{}_qvality_input.txt'.format(t_or_d)
            writers.write_qvality_input(self.scores[t_or_d]['scores'],
                                        self.scores[t_or_d]['fn'])
411654
def score(self, report):
        """"""
        score = 0

        try:
            # cuckoo-modified format
            score = report['malscore']
        except KeyError:
            # cuckoo-2.0 format
            score = report.get('info', {}).get('score', 0)

        return score
689519
def encrypted_score(self, x):
        """"""
        score = self.intercept
        _, idx = x.nonzero()
        for i in idx:
            score += x[0, i] * self.weights[i]
        return score
428895
def weights(value):
    
    probs = probabilities(value)
    if abs(sum(probs) - 1.) > PRECISION:
        raise ValueError('The weights do not sum up to 1: %s' % probs)
    return probs
175506
def init_weights(self):
        """"""

        self.W = np.random.randn(self.n_neurons, self.n_inputs) * np.sqrt(2 / self.n_inputs)
        self.b = np.zeros((self.n_neurons, 1))
1173922
def weighted_choice(item_probabilities):
    
    probability_sum = sum(x[1] for x in item_probabilities)
    assert probability_sum > 0
    random_value = random.random() * probability_sum
    summed_probability = 0
    for item, value in item_probabilities:
        summed_probability += value
        if summed_probability > random_value:
            return item
481934
def initialize_weights(self):
        """"""
        n = self._outputSize
        m = self._inputSize
        self._Q = self._random.sample((n,m))

        # Normalize the weights of each units
        for i in range(n):
            self._Q[i] /=  np.sqrt( np.dot(self._Q[i], self._Q[i]) )
30044
def _ss_tot(self):
        """"""
        return np.sum(
            np.square(self.ywins - np.expand_dims(self._ybar, axis=-1)), axis=1
        )
1132017
public static <S extends Solution<?>> void weightedSum(List<S> solutionsList, double[] weights) {
    for (S solution : solutionsList) {
      double sum = weights[0] * solution.getObjective(0);
      for (int i = 1; i < solution.getNumberOfObjectives(); i++) {
        sum += weights[i] * solution.getObjective(i);
      }
      setScalarizationValue(solution, sum);
    }

  }
1307779
def _set_scores(self):
        
        anom_scores = {}
        self._generate_SAX()
        self._construct_all_SAX_chunk_dict()
        length = self.time_series_length
        lws = self.lag_window_size
        fws = self.future_window_size

        for i, timestamp in enumerate(self.time_series.timestamps):
            if i < lws or i > length - fws:
                anom_scores[timestamp] = 0
            else:
                anom_scores[timestamp] = self._compute_anom_score_between_two_windows(i)
        self.anom_scores = TimeSeries(self._denoise_scores(anom_scores))
1153559
def standardize(score):
    """"""
    score = asarray_ndim(score, 1)
    return (score - np.nanmean(score)) / np.nanstd(score)
585387
def setup_auxiliary_weights(self):
        
        if self.fk.isAPF:
            self.logetat = self.fk.logeta(self.t - 1, self.X)
            self.aux = self.wgts.add(self.logetat)
        else:
            self.aux = self.wgts