Example #1
0
    def _compute_vectorized(self, s_left, s_right):

        d = _1d_distance(s_left, s_right)

        if self.method == 'step':
            num_sim_alg = partial(_step_sim, d, self.offset, self.origin)
        elif self.method in ['linear', 'lin']:
            num_sim_alg = partial(_linear_sim, d, self.scale, self.offset,
                                  self.origin)
        elif self.method == 'squared':
            num_sim_alg = partial(_squared_sim, d, self.scale, self.offset,
                                  self.origin)
        elif self.method in ['exp', 'exponential']:
            num_sim_alg = partial(_exp_sim, d, self.scale, self.offset,
                                  self.origin)
        elif self.method in ['gauss', 'gaussian']:
            num_sim_alg = partial(_gauss_sim, d, self.scale, self.offset,
                                  self.origin)
        else:
            raise ValueError("The algorithm '{}' is not known.".format(
                self.method))

        c = num_sim_alg()
        c = _fillna(c, self.missing_value)
        return c
Example #2
0
        def _num_internal(s1, s2, call_method, *args, **kwargs):
            """Internal function to compute the numeric similarity."""

            # compute the 1D distance between the values
            d = _1d_distance(s1, s2)

            return call_method(d, *args, **kwargs)
Example #3
0
        def _num_internal(s1, s2, method, *args, **kwargs):
            """

            Internal function to compute the numeric similarity algorithms.

            """

            # compute the 1D distance between the values
            d = _1d_distance(s1, s2)

            if method == 'step':
                num_sim_alg = _step_sim
            elif method in ['linear', 'lin']:
                num_sim_alg = _linear_sim
            elif method == 'squared':
                num_sim_alg = _squared_sim
            elif method in ['exp', 'exponential']:
                num_sim_alg = _exp_sim
            elif method in ['gauss', 'gaussian']:
                num_sim_alg = _gauss_sim
            else:
                raise ValueError("The algorithm '{}' is not known.".format(method))

            return num_sim_alg(d, *args, **kwargs)
Example #4
0
        def _num_internal(s1, s2, method, *args, **kwargs):
            """

            Internal function to compute the numeric similarity algorithms.

            """

            # compute the 1D distance between the values
            d = _1d_distance(s1, s2)

            if method == 'step':
                num_sim_alg = _step_sim
            elif method in ['linear', 'lin']:
                num_sim_alg = _linear_sim
            elif method == 'squared':
                num_sim_alg = _squared_sim
            elif method in ['exp', 'exponential']:
                num_sim_alg = _exp_sim
            elif method in ['gauss', 'gaussian']:
                num_sim_alg = _gauss_sim
            else:
                raise ValueError("The algorithm '{}' is not known.".format(method))

            return num_sim_alg(d, *args, **kwargs)