'Allocate mem for parameters; initialize if provided.'

def _allocate_parameter_mem(self, n_classes, n_features, coef_init=None, intercept_init=None):

    if (n_classes > 2):
        if (coef_init is not None):
            coef_init = np.asarray(coef_init, order='C')
            if (coef_init.shape != (n_classes, n_features)):
                raise ValueError('Provided    ``coef_``    does    not    match    dataset.    ')
            self.coef_ = coef_init
        else:
            self.coef_ = np.zeros((n_classes, n_features), dtype=np.float64, order='C')
        if (intercept_init is not None):
            intercept_init = np.asarray(intercept_init, order='C')
            if (intercept_init.shape != (n_classes,)):
                raise ValueError('Provided    intercept_init    does    not    match    dataset.')
            self.intercept_ = intercept_init
        else:
            self.intercept_ = np.zeros(n_classes, dtype=np.float64, order='C')
    else:
        if (coef_init is not None):
            coef_init = np.asarray(coef_init, dtype=np.float64, order='C')
            coef_init = coef_init.ravel()
            if (coef_init.shape != (n_features,)):
                raise ValueError('Provided    coef_init    does    not    match    dataset.')
            self.coef_ = coef_init
        else:
            self.coef_ = np.zeros(n_features, dtype=np.float64, order='C')
        if (intercept_init is not None):
            intercept_init = np.asarray(intercept_init, dtype=np.float64)
            if ((intercept_init.shape != (1,)) and (intercept_init.shape != ())):
                raise ValueError('Provided    intercept_init    does    not    match    dataset.')
            self.intercept_ = intercept_init.reshape(1)
        else:
            self.intercept_ = np.zeros(1, dtype=np.float64, order='C')
    if (self.average > 0):
        self.standard_coef_ = self.coef_
        self.standard_intercept_ = self.intercept_
        self.average_coef_ = np.zeros(self.coef_.shape, dtype=np.float64, order='C')
        self.average_intercept_ = np.zeros(self.standard_intercept_.shape, dtype=np.float64, order='C')
