File size: 861 Bytes
6d95c4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from abc import ABC
from abc import abstractmethod
import warnings
from joblib import load

from . import constants

# Silence xgboost warnings
warnings.filterwarnings("ignore")

class Predictor(ABC):
    """
    Abstract class for predictor models to inherit.
    """

    @abstractmethod
    def predict(self, input):
        """
        Input columns: CONTEXT_COLUMNS + DIFF_LAND_USE_COLS indexed by INDEX_COLS in constants.py
        Output columns: ELUC float
        Check output validity: scale of ELUC tC/ha caused by land use change passed in input
        """
        pass


class SkLearnPredictor(Predictor):
    def __init__(self, load_path):
        self.model = load(load_path)

    def predict(self, input):
        pred = self.model.predict(input)
        return pred[0]
    

class CustomPredictor(Predictor):
    """ You fill in here: """