Skip to content

Commit

Permalink
fix rule extractor report
Browse files Browse the repository at this point in the history
  • Loading branch information
itlubber committed Feb 29, 2024
1 parent 25ce968 commit 70d01cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scorecardpipeline/rule_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,30 +325,30 @@ def report(self, valid=None, sheet="组合策略汇总", save=None):
if self.feature_map is not None and len(self.feature_map) > 0:
parsed_rules_train["组合策略"] = parsed_rules_train["组合策略"].replace(self.feature_map, regex=True)

self.end_row, _ = self.writer.insert_value2sheet(worksheet, (2 if sheet else self.end_row + 2, self.start_col), value="组合策略: 训练集", style="header_middle", end_space=(2 if sheet else self.end_row + 2, self.start_col + len(parsed_rules_train.columns)))
self.end_row, _ = self.writer.insert_value2sheet(worksheet, (2 if sheet else self.end_row + 2, self.start_col), value="组合策略: 训练集", style="header_middle", end_space=(2 if sheet else self.end_row + 2, self.start_col + len(parsed_rules_train.columns) - 1))
self.end_row, _ = self.insert_dt_rules(parsed_rules_train, self.end_row, self.start_col, sheet=worksheet)
outputs = (parsed_rules_train,)

if valid is not None:
if isinstance(valid, pd.DataFrame) and len(valid) > 0:
parsed_rules_val = self.transform(valid)
self.end_row, _ = self.writer.insert_value2sheet(worksheet, (self.end_row + 2, self.start_col), value="组合策略: 验证集", style="header_middle", end_space=(self.end_row + 2, self.start_col + len(parsed_rules_val.columns)))
self.end_row, _ = self.writer.insert_value2sheet(worksheet, (self.end_row + 2, self.start_col), value="组合策略: 验证集", style="header_middle", end_space=(self.end_row + 2, self.start_col + len(parsed_rules_val.columns) - 1))
self.end_row, _ = self.insert_dt_rules(parsed_rules_val, self.end_row, self.start_col, sheet=worksheet)
outputs = outputs + (parsed_rules_val,)

elif isinstance(valid, (list, tuple)):
for i, dataset in enumerate(valid):
if isinstance(dataset, pd.DataFrame) and len(dataset) > 0:
parsed_rules_val = self.transform(dataset)
self.end_row, _ = self.writer.insert_value2sheet(worksheet, (self.end_row + 2, self.start_col), value=f"组合策略: 验证集 {i + 1}", style="header_middle", end_space=(self.end_row + 2, self.start_col + len(parsed_rules_val.columns)))
self.end_row, _ = self.writer.insert_value2sheet(worksheet, (self.end_row + 2, self.start_col), value=f"组合策略: 验证集 {i + 1}", style="header_middle", end_space=(self.end_row + 2, self.start_col + len(parsed_rules_val.columns) - 1))
self.end_row, _ = self.insert_dt_rules(parsed_rules_val, self.end_row, self.start_col, sheet=worksheet)
outputs = outputs + (parsed_rules_val,)

elif isinstance(valid, dict):
for k, dataset in valid.items():
if isinstance(dataset, pd.DataFrame) and len(dataset) > 0:
parsed_rules_val = self.transform(dataset)
self.end_row, _ = self.writer.insert_value2sheet(worksheet, (self.end_row + 2, self.start_col), value=f"组合策略: {k}", style="header_middle", end_space=(self.end_row + 2, self.start_col + len(parsed_rules_val.columns)))
self.end_row, _ = self.writer.insert_value2sheet(worksheet, (self.end_row + 2, self.start_col), value=f"组合策略: {k}", style="header_middle", end_space=(self.end_row + 2, self.start_col + len(parsed_rules_val.columns) - 1))
self.end_row, _ = self.insert_dt_rules(parsed_rules_val, self.end_row, self.start_col, sheet=worksheet)
outputs = outputs + (parsed_rules_val,)

Expand Down

0 comments on commit 70d01cb

Please sign in to comment.