|
|
|
@ -14,11 +14,11 @@ class MVStrategy(ABC):
|
|
|
|
|
return df
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def list_available(series: Series) -> list['MVStrategy']:
|
|
|
|
|
def list_available(df: DataFrame, series: Series) -> list['MVStrategy']:
|
|
|
|
|
"""Get all the strategies that can be used."""
|
|
|
|
|
choices = [DropStrategy(), ModeStrategy()]
|
|
|
|
|
if is_numeric_dtype(series):
|
|
|
|
|
choices.extend((MeanStrategy(), MedianStrategy()))
|
|
|
|
|
choices.extend((MeanStrategy(), MedianStrategy(), LinearRegressionStrategy()))
|
|
|
|
|
return choices
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -68,3 +68,12 @@ class ModeStrategy(PositionStrategy):
|
|
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
|
return "Use mode"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LinearRegressionStrategy(MVStrategy):
|
|
|
|
|
def apply(self, df: DataFrame, label: str, series: Series) -> DataFrame:
|
|
|
|
|
series.interpolate(inplace=True)
|
|
|
|
|
return df
|
|
|
|
|
|
|
|
|
|
def __str__(self) -> str:
|
|
|
|
|
return "Use linear regression"
|
|
|
|
|