compute type probabilities given current parameter estimates.
177935
def E_step(self):

        

        # on the first iteration of estimation, this will be called
        if not hasattr(self, 'type_prob'):
                self.type_prob = np.empty((self.N, self.K))

        temp_probs = np.zeros((self.N, self.K))

        for i in range(self.N):
            for k in range(self.K):
                temp_probs[i, k] = \
                    np.log(self.rho[k]) + np.dot(self.feature_counts[i, :],
                                                 np.log(self.mu[k, :]))

        temp_probsZ = temp_probs - np.max(temp_probs, axis=1)[:, np.newaxis]
        self.type_prob = np.exp(temp_probsZ) / \
            np.exp(temp_probsZ).sum(axis=1)[:, np.newaxis]

        return np.log(np.exp(temp_probsZ).sum(axis=1)).sum() + \
            np.max(temp_probs, axis=1).sum()
1272486
def p_sigtypes(self, p):
        ''
        p[0] = p[1] + (p[2],)
        p.set_lineno(0, p.lineno(1))
14240
def _get_likelihoods(self, X):
        """"""

        n_samples = np.shape(X)[0]
        likelihoods = np.zeros((n_samples, self.k))
        for i in range(self.k):
            likelihoods[:, i] = self.multivariate_gaussian(X, self.parameters[i])

        return likelihoods
270231
def _guess_type(val):
        """"""
        if isinstance(val, bool):
            return "choice"
        elif isinstance(val, int):
            return "number"
        elif isinstance(val, float):
            return "number"
        elif isinstance(val, str):
            return "text"
        elif hasattr(val, 'read'):
            return "file"
        else:
            return "text"
1360060
def _compute_state_estimate(self):
        
        self.x.fill(0)
        for f, mu in zip(self.filters, self.mu):
            self.x += f.x * mu

        self.P.fill(0)
        for f, mu in zip(self.filters, self.mu):
            y = f.x - self.x
            self.P += mu * (outer(y, y) + f.P)
1294164
def validate_noise_probabilities(noise_parameter):
    
    if not noise_parameter:
        return
    if not isinstance(noise_parameter, list):
        raise TypeError("noise_parameter must be a list")
    if any([not isinstance(value, float) for value in noise_parameter]):
        raise TypeError("noise_parameter values should all be floats")
    if len(noise_parameter) != 3:
        raise ValueError("noise_parameter lists must be of length 3")
    if sum(noise_parameter) > 1 or sum(noise_parameter) < 0:
        raise ValueError("sum of entries in noise_parameter must be between 0 and 1 (inclusive)")
    if any([value < 0 for value in noise_parameter]):
        raise ValueError("noise_parameter values should all be non-negative")
311238
def p_param_types(self, p):
        ''''''
        if len(p) == 2:
            p[0] = tuple((t,) for t in p[1])
        elif len(p) == 3:
            p[0] = tuple((t,) for t in p[1]) + ((),)
        elif len(p) == 4:
            p[0] = tuple((t,) + ts for t in p[1] for ts in p[3])
        else:
            non_defaults = [t for t in p[4] if len(t) == len(p[4][0])]
            p[0] = tuple((t,) + ts for t in p[1] for ts in non_defaults) + p[4]
1108082
def iteration_stats(self, k, frcxd):
        """"""

        tk = self.timer.elapsed(self.opt['IterTimer'])
        tpl = (k,) + self.eval_objfn() + \
            (frcxd, self.F, self.Q, self.iterBTrack, self.L) + \
            self.itstat_extra() + (tk,)
        return type(self).IterationStats(*tpl)
487108
def eval_proxop(self, V):
        """"""

        return np.asarray(sp.prox_l1(V, (self.lmbda / self.L) * self.wl1),
                          dtype=self.dtype)
795243
def probabilities(self) -> bk.BKTensor:
        
        value = bk.absolute(self.tensor)
        return value * value
914709
def computePredictionAccuracy(pac, pic):
  
  pcols = float(pac + pic)
  if pcols == 0:
    return 0.0
  else:
    return (pac / pcols)
808341
def type_cast_params(num_bins, edge_range_spec, features, groups):
    """"""

    if isinstance(num_bins, str):
        # possible when called from CLI
        num_bins = np.float(num_bins)

    # rounding it to ensure it is int
    num_bins = np.rint(num_bins)

    if np.isnan(num_bins) or np.isinf(num_bins):
        raise ValueError('Invalid value for number of bins! Choose a natural number >= {}'.format(minimum_num_bins))

    if edge_range_spec is None:
        edge_range = edge_range_spec
    elif isinstance(edge_range_spec, collections.Sequence):
        if len(edge_range_spec) != 2:
            raise ValueError('edge_range must be a tuple of two values: (min, max)')
        if edge_range_spec[0] >= edge_range_spec[1]:
            raise ValueError('edge_range : min {} is not less than the max {} !'.format(edge_range_spec[0], edge_range_spec[1]))
        if not np.all(np.isfinite(edge_range_spec)):
            raise ValueError('Infinite or NaN values in edge range : {}'.format(edge_range_spec))

        # converting it to tuple to make it immutable
        edge_range = tuple(edge_range_spec)
    else:
        raise ValueError('Invalid edge range! Must be a tuple of two values (min, max)')

    if not isinstance(features, np.ndarray):
        features = np.array(features)

    if not isinstance(groups, np.ndarray):
        groups = np.array(groups)

    return num_bins, edge_range, features, groups
1337693
def convenience_calc_probs(self, params):
        
        shapes, intercepts, betas = self.convenience_split_params(params)

        prob_args = [betas,
                     self.design,
                     self.alt_id_vector,
                     self.rows_to_obs,
                     self.rows_to_alts,
                     self.utility_transform]

        prob_kwargs = {"intercept_params": intercepts,
                       "shape_params": shapes,
                       "chosen_row_to_obs": self.chosen_row_to_obs,
                       "return_long_probs": True}
        prob_results = cc.calc_probabilities(*prob_args, **prob_kwargs)

        return prob_results
598917
def _compute(self):
        """"""
        tendencies = {}
        for name, value in self.state.items():
            tendencies[name] = value * 0.
        return tendencies
548216
def postprocessor(prediction):
    """"""
    prediction = prediction.data.numpy()[0]
    top_predictions = prediction.argsort()[-3:][::-1]
    return [labels[prediction] for prediction in top_predictions]
310903
def check_type(self):
        """"""
        self.isdiscrete = {}
        for stochastic in self.stochastics:
            if stochastic.dtype in integer_dtypes:
                self.isdiscrete[stochastic] = True
            elif stochastic.dtype in bool_dtypes:
                raise ValueError(
                    'Binary stochastics not supported by AdaptativeMetropolis.')
            else:
                self.isdiscrete[stochastic] = False
945938
private void calcAxisFoldTypes() {
		axisTypes = new int[multiplicity];

		for (int i=0;i<this.transformations.size();i++){

			axisTypes[i] = getRotAxisType(transformations.get(i));

		}
	}