Exemple #1
0
        def _num_internal(lat1, lng1, lat2, lng2, method, *args, **kwargs):
            """

            Internal function to compute the numeric similarity algorithms.

            """

            # compute the 1D distance between the values
            d = _haversine_distance(lat1, lng1, lat2, lng2)

            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)
Exemple #2
0
    def _compute_vectorized(self, lat1, lng1, lat2, lng2):

        d = _haversine_distance(lat1, lng1, lat2, lng2)

        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
Exemple #3
0
        def _num_internal(lat1, lng1, lat2, lng2, method, *args, **kwargs):
            """

            Internal function to compute the numeric similarity algorithms.

            """

            # compute the 1D distance between the values
            d = _haversine_distance(lat1, lng1, lat2, lng2)

            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)
Exemple #4
0
        def _num_internal(lat1, lng1, lat2, lng2, call_method, *args,
                          **kwargs):
            """Internal function to compute the numeric similarity algorithms."""

            # compute the 1D distance between the values
            d = _haversine_distance(lat1, lng1, lat2, lng2)

            return call_method(d, *args, **kwargs)
Exemple #5
0
    def _compute_vectorized(self, lat1, lng1, lat2, lng2):

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

        d = _haversine_distance(lat1, lng1, lat2, lng2)
        c = num_sim_alg(d, *self.args, **self.kwargs)
        c = fillna(c)
        return c
 def comparator(x, y):
     dist = _haversine_distance(*[*x, *y])
     return _exp_sim(
         np.float32(dist),
         scale=np.float32(0.1),
         offset=np.float32(0.01))
Exemple #7
0
def _geo_internal(lat1, lng1, lat2, lng2, call_method, *args, **kw):

    # compute the 1D distance between the values
    d = _haversine_distance(lat1, lng1, lat2, lng2)

    return call_method(d, *args, **kw)