remove special characters from feature names

This commit is contained in:
robcaulk 2022-11-03 18:49:39 +01:00
parent b3b756ec14
commit 6c4bdb8f67
3 changed files with 18 additions and 2 deletions

View File

@ -98,7 +98,6 @@ class FreqaiDataDrawer:
"model_filename": "", "trained_timestamp": 0, "model_filename": "", "trained_timestamp": 0,
"data_path": "", "extras": {}} "data_path": "", "extras": {}}
self.metric_tracker: Dict[str, Dict[str, Dict[str, list]]] = {} self.metric_tracker: Dict[str, Dict[str, Dict[str, list]]] = {}
self.current_candle: datetime = datetime.fromtimestamp(637887600)
def update_metric_tracker(self, metric: str, value: float, pair: str) -> None: def update_metric_tracker(self, metric: str, value: float, pair: str) -> None:
""" """

View File

@ -1247,6 +1247,8 @@ class FreqaiDataKitchen:
self.get_unique_classes_from_labels(dataframe) self.get_unique_classes_from_labels(dataframe)
dataframe = self.remove_special_chars_from_feature_names(dataframe)
return dataframe return dataframe
def fit_labels(self) -> None: def fit_labels(self) -> None:
@ -1335,3 +1337,16 @@ class FreqaiDataKitchen:
f"Could not find backtesting prediction file at {path_to_predictionfile}" f"Could not find backtesting prediction file at {path_to_predictionfile}"
) )
return file_exists return file_exists
def remove_special_chars_from_feature_names(self, dataframe: pd.DataFrame) -> pd.DataFrame:
"""
Remove all special characters from feature strings (:)
:param dataframe: the dataframe that just finished indicator population. (unfiltered)
:return: dataframe with cleaned featrue names
"""
spec_chars = [':']
for c in spec_chars:
dataframe.columns = dataframe.columns.str.replace(c, "")
return dataframe

View File

@ -68,6 +68,9 @@ class IFreqaiModel(ABC):
if self.save_backtest_models: if self.save_backtest_models:
logger.info('Backtesting module configured to save all models.') logger.info('Backtesting module configured to save all models.')
self.dd = FreqaiDataDrawer(Path(self.full_path), self.config, self.follow_mode) self.dd = FreqaiDataDrawer(Path(self.full_path), self.config, self.follow_mode)
# set current candle to arbitrary historical date
self.current_candle: datetime = datetime.fromtimestamp(637887600, tz=timezone.utc)
self.dd.current_candle = self.current_candle
self.scanning = False self.scanning = False
self.ft_params = self.freqai_info["feature_parameters"] self.ft_params = self.freqai_info["feature_parameters"]
self.corr_pairlist: List[str] = self.ft_params.get("include_corr_pairlist", []) self.corr_pairlist: List[str] = self.ft_params.get("include_corr_pairlist", [])
@ -93,7 +96,6 @@ class IFreqaiModel(ABC):
# get_corr_dataframes is controlling the caching of corr_dataframes # get_corr_dataframes is controlling the caching of corr_dataframes
# for improved performance. Careful with this boolean. # for improved performance. Careful with this boolean.
self.get_corr_dataframes: bool = True self.get_corr_dataframes: bool = True
self.current_candle: datetime = datetime.fromtimestamp(637887600, tz=timezone.utc)
self._threads: List[threading.Thread] = [] self._threads: List[threading.Thread] = []
self._stop_event = threading.Event() self._stop_event = threading.Event()