File size: 1,229 Bytes
9af7384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import numpy as np

from ..base import Base


class Random(Base):
    """
    Class to randomly interpolate by picking values between maximum and
    minimum measurements.

    Note: Even if a point on the requested grid is present in
    the training set, we return a random value for it.
    """

    def __init__(self, resolution="standard", coordinate_type="Euclidean"):
        super().__init__(resolution, coordinate_type)

    def _fit(self, X, y):
        """Function for fitting random interpolation.
        This function is not supposed to be called directly.
        """
        self.ymax = max(y)
        self.ymin = min(y)
        return self

    def _predict_grid(self, x1lim, x2lim):
        """Function for random grid interpolation.
        This function is not supposed to be called directly.
        """
        return np.random.uniform(
            low=self.ymin,
            high=self.ymax,
            size=(self.resolution, self.resolution),
        )

    def _predict(self, X):
        """Function for random interpolation.
        This function is not supposed to be called directly.
        """
        return np.random.uniform(
            low=self.ymin, high=self.ymax, size=(X.shape[0])
        )