Beispiel #1
0
def z_score(x, axis=None):
    if not isinstance(x, R.Tensor):
        x = R.Tensor(x)

    if axis is not None:
        mean = R.mean(x, axis=axis)
        std = R.std(x, axis=axis)
    else:
        mean = R.mean(x)
        std = R.std(x)

    return R.div(R.sub(x, mean), std)
Beispiel #2
0
    def start_info(self, X):
        """
        Calculate mean and standard deviation
        """

        for feature in zip(*X):
            yield {'std': R.std(feature), 'mean': R.mean(features)}
Beispiel #3
0
def standardize(x):
    """
    Standardize an array
    """
    if not isinstance(x, R.Tensor):
        x = R.Tensor(x)

    mean = R.mean(x)
    std = R.std(x)

    return R.div(R.sub(x, mean), std)
Beispiel #4
0
    def stat_info(self, X):

        """
        Calculate mean and standard deviation
        """

        for feature in zip(*X):

            feature = R.Tensor(list(feature), name = 'feature')
            std = R.std(feature)
            mean = R.mean(feature)
            yield {
                'std': std,
                'mean': mean
            }