Add ObjectiveValueComponent.xy

This commit is contained in:
2021-03-30 17:17:29 -05:00
parent 9266743940
commit e8adeb28a3
5 changed files with 46 additions and 4 deletions

View File

@@ -136,8 +136,8 @@ class Component(ABC):
) -> None:
return
@staticmethod
def xy(
self,
instance: Any,
training_sample: TrainingSample,
) -> Tuple[Dict, Dict]:

View File

@@ -3,7 +3,7 @@
# Released under the modified BSD license. See COPYING.md for more details.
import logging
from typing import List, Dict, Union, Callable, Optional, Any, TYPE_CHECKING
from typing import List, Dict, Union, Callable, Optional, Any, TYPE_CHECKING, Tuple
import numpy as np
from sklearn.linear_model import LinearRegression
@@ -161,3 +161,21 @@ class ObjectiveValueComponent(Component):
},
}
return ev
@staticmethod
def xy(
instance: Any,
sample: TrainingSample,
) -> Tuple[Dict, Dict]:
x: Dict = {}
y: Dict = {}
if "Lower bound" not in sample:
return x, y
features = instance.get_instance_features()
if "LP value" in sample and sample["LP value"] is not None:
features += [sample["LP value"]]
x["Lower bound"] = [features]
x["Upper bound"] = [features]
y["Lower bound"] = [[sample["Lower bound"]]]
y["Upper bound"] = [[sample["Upper bound"]]]
return x, y

View File

@@ -297,8 +297,8 @@ class PrimalSolutionComponent(Component):
)
return [opt_value < 0.5, opt_value > 0.5]
@staticmethod
def xy(
self,
instance: Any,
sample: TrainingSample,
) -> Tuple[Dict, Dict]: