Applies TTA to predict on `ds_type` dataset.
773316
def _TTA(learn:Learner, beta:float=0.4, scale:float=1.35, ds_type:DatasetType=DatasetType.Valid, with_loss:bool=False) -> Tensors:
    ""
    preds,y = learn.get_preds(ds_type)
    all_preds = list(learn.tta_only(scale=scale, ds_type=ds_type))
    avg_preds = torch.stack(all_preds).mean(0)
    if beta is None: return preds,avg_preds,y
    else:            
        final_preds = preds*beta + avg_preds*(1-beta)
        if with_loss: 
            with NoneReduceOnCPU(learn.loss_func) as lf: loss = lf(final_preds, y)
            return final_preds, y, loss
        return final_preds, y
567485
def _ttr(self, k, dist, cache):
        """"""
        a,b = evaluation.evaluate_recurrence_coefficients(dist, k)
        return -a, b
1157949
def _dts_from_da(da, tspan, labels):
    """"""
    sublabels = labels[:]
    new_subarrays = []
    for i, ra in enumerate(da._subarrays):
        if isinstance(ra, RemoteTimeseries):
            new_subarrays.append(ra)
        else:
            if labels[da._distaxis]:
                sublabels[da._distaxis] = labels[da._distaxis][
                        da._si[i]:da._si[i+1]]
            new_subarrays.append(_rts_from_ra(ra, tspan, sublabels, False))
    new_subarrays = [distob.convert_result(ar) for ar in new_subarrays]
    da._subarrays = new_subarrays
    da.__class__ = DistTimeseries
    da.tspan = tspan
    da.labels = labels
    da.t = _Timeslice(da)
    return da
987727
def W(self,value):
        
        if value is None:   value = sp.zeros((self._N, 0))
        assert value.shape[0]==self._N, 'Dimension mismatch'
        self._K = value.shape[1]
        self._W = value
        self._notify()
        self.clear_cache('predict_in_sample','Yres')
1085094
def _guess_x_simple(self, y_desired, y_dims=None, **kwargs):
        """"""
        _, indexes = self.fmodel.dataset.nn_y(y_desired, dims=y_dims, k = 10)
        return [self.fmodel.get_x(i) for i in indexes]
119804
def predict(self, x, *args, **kwargs):
        
        if not self.model:
            raise Exception('Not trained. Train first')

        points = self._dimensionality_check(x, ext='points')

        return self.execute(points, *args, **kwargs)[0]
237374
def dl(self, ds_type:DatasetType=DatasetType.Valid)->DeviceDataLoader:
        ""
        #TODO: refactor
        return (self.train_dl if ds_type == DatasetType.Train else
                self.test_dl if ds_type == DatasetType.Test else
                self.valid_dl if ds_type == DatasetType.Valid else
                self.single_dl if ds_type == DatasetType.Single else
                self.fix_dl)
981745
def _ss_reg(self):
        """"""
        return np.sum(
            np.square(self._predicted - np.expand_dims(self._ybar, axis=1)),
            axis=1,
        )
221415
def predict(self, predict_set ):
        
        predict_data           = np.array( [instance.features for instance in predict_set ] )
        
        return self.update( predict_data )
1129203
@Override
    public int predict(T x) {
        List<Neighbor<T,T>> neighbors = new ArrayList<>();
        nns.range(x, radius, neighbors);
        
        if (neighbors.size() < minPts) {
            return OUTLIER;
        }
        
        int[] label = new int[k + 1];
        for (Neighbor<T,T> neighbor : neighbors) {
            int yi = y[neighbor.index];
            if (yi == OUTLIER) yi = k;
            label[yi]++;
        }
        
        int c = Math.whichMax(label);
        if (c == k) c = OUTLIER;
        return c;
    }
1299120
def Wstar(self,value):
        
        if value is None:
            self._use_to_predict = False
        else:
            assert value.shape[1]==self._K, 'Dimension mismatch'
            self._use_to_predict = True
        self._Wstar = value
        self.clear_cache('predict')
1060418
def one_batch(self, ds_type:DatasetType=DatasetType.Train, detach:bool=True, denorm:bool=True, cpu:bool=True)->Collection[Tensor]:
        ""
        dl = self.dl(ds_type)
        w = self.num_workers
        self.num_workers = 0
        try:     x,y = next(iter(dl))
        finally: self.num_workers = w
        if detach: x,y = to_detach(x,cpu=cpu),to_detach(y,cpu=cpu)
        norm = getattr(self,'norm',False)
        if denorm and norm:
            x = self.denorm(x)
            if norm.keywords.get('do_y',False): y = self.denorm(y, do_x=True)
        return x,y
380705
def run_MDR(n,stack_float,labels=None):
    """"""
    # need to check that tmp is categorical

    x1 = stack_float.pop()
    x2 = stack_float.pop()
    # check data is categorical
    if len(np.unique(x1))<=3 and len(np.unique(x2))<=3:
        tmp = np.vstack((x1,x2)).transpose()

        if labels is None: # prediction
            return n.model.transform(tmp)[:,0]
        else: # training
            out =  n.model.fit_transform(tmp,labels)[:,0]

            return out
    else:
        return np.zeros(x1.shape[0])
427448
def calculate_traditional_regressor_output_shapes(operator):
    '''
    
    '''
    check_input_and_output_types(operator, good_input_types=[FloatTensorType, Int64TensorType, FloatType, Int64Type])

    if any(len(variable.type.shape) != 2 for variable in operator.inputs):
        raise RuntimeError('Input(s) must be 2-D tensor(s)')

    model_type = operator.raw_operator.WhichOneof('Type')
    if model_type == 'glmRegressor':
        glm = operator.raw_operator.glmRegressor
        C = len(glm.weights)
    elif model_type == 'treeEnsembleRegressor':
        tree = operator.raw_operator.treeEnsembleRegressor.treeEnsemble
        C = len(tree.basePredictionValue)
    elif model_type == 'supportVectorRegressor':
        C = 1
    else:
        raise ValueError('Model should be one of linear model, tree-based model, and support vector machine')

    N = operator.inputs[0].type.shape[0]
    operator.outputs[0].type = FloatTensorType([N, C], doc_string=operator.outputs[0].type.doc_string)
794425
private void applyL2Reg(final double eta_t)
    {
        if(lambda0 > 0)//apply L2 regularization
            for(Vec v : ws)
                v.mutableMultiply(1-eta_t*lambda0);
    }
658242
def predict(abg,date,obs=568):
    """"""
    import orbfit
    import RO.StringUtil
    (ra,dec,a,b,ang) = orbfit.predict(abg,date,obs)
    obj['RA']=ra
    obj['DEC']=dec
    obj['dRA']=a
    obj['dDEC']=b
    obj['dANG']=ang
    return obj
492323
def fit_predict(self, X, y=None, **kwargs):
        
        return self.fit(X, **kwargs).predict(X, **kwargs)