ripple-down-rules 0.6.18__py3-none-any.whl → 0.6.19__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- __version__ = "0.6.18"
1
+ __version__ = "0.6.19"
2
2
 
3
3
  import logging
4
4
  logger = logging.Logger("rdr")
@@ -34,7 +34,8 @@ class RDRDecorator:
34
34
  package_name: Optional[str] = None,
35
35
  use_generated_classifier: bool = False,
36
36
  ask_now: Callable[Dict[str, Any], bool] = lambda _: True,
37
- fitting_decorator: Optional[Callable] = None):
37
+ fitting_decorator: Optional[Callable] = None,
38
+ generate_dot_file: bool = False) -> None:
38
39
  """
39
40
  :param models_dir: The directory to save/load the RDR models.
40
41
  :param output_type: The type of the output. This is used to create the RDR model.
@@ -51,6 +52,10 @@ class RDRDecorator:
51
52
  :param viewer: The viewer to use for the RDR model. If None, no viewer will be used.
52
53
  :param package_name: The package name to use for relative imports in the RDR model.
53
54
  :param use_generated_classifier: If True, the function will use the generated classifier instead of the RDR model.
55
+ :param ask_now: A callable that takes the case dictionary and returns True if the user should be asked for
56
+ the output, or False if the function should return the output without asking.
57
+ :param fitting_decorator: A decorator to use for the fitting function. If None, no decorator will be used.
58
+ :param generate_dot_file: If True, the RDR model will generate a dot file for visualization.
54
59
  :return: A decorator to use a GeneralRDR as a classifier that monitors and modifies the function's output.
55
60
  """
56
61
  self.rdr_models_dir = models_dir
@@ -69,6 +74,7 @@ class RDRDecorator:
69
74
  self.ask_now = ask_now
70
75
  self.fitting_decorator = fitting_decorator if fitting_decorator is not None else \
71
76
  lambda f: f # Default to no fitting decorator
77
+ self.generate_dot_file = generate_dot_file
72
78
  self.load()
73
79
 
74
80
  def decorator(self, func: Callable) -> Callable:
@@ -110,6 +116,8 @@ class RDRDecorator:
110
116
  output = self.generated_classifier(case)
111
117
  else:
112
118
  output = self.rdr.classify(case)
119
+ if self.generate_dot_file:
120
+ self.rdr.render_evaluated_rule_tree(self.rdr_models_dir + f'/{self.model_name}')
113
121
 
114
122
  if self.output_name in output:
115
123
  return output[self.output_name]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.6.18
3
+ Version: 0.6.19
4
4
  Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
5
5
  Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -1,8 +1,8 @@
1
- ripple_down_rules/__init__.py,sha256=Vs-U6OcpBqoEUmJvCkWrHejd0cjJTQP8Gsu5bkR4Pds,100
1
+ ripple_down_rules/__init__.py,sha256=SI5OK8zlaHJ4LnHNQ1hp0L91Xem5KQsF_6uS7NrGzVU,100
2
2
  ripple_down_rules/experts.py,sha256=4-dMIVeMzFXCLYl_XBG_P7_Xs4sZih9-vZxCIPri6dA,12958
3
3
  ripple_down_rules/helpers.py,sha256=RUdfiSWMZjGwCxuCy44TcEJf2UNAFlPJusgHzuAs6qI,4583
4
4
  ripple_down_rules/rdr.py,sha256=mtY_kBOjUXRZYz4QFaKN6C2O7liFpbMdnjUnFFnXbdU,57550
5
- ripple_down_rules/rdr_decorators.py,sha256=j_bIv30nonWz-D5em7dYnV3htlklar2QwFRa5o48XYM,10707
5
+ ripple_down_rules/rdr_decorators.py,sha256=fxoMMAZB1HTfEsuzfIdo3b7PiPB_-AAjD8hy4L0sawQ,11389
6
6
  ripple_down_rules/rules.py,sha256=ULIHRbVfKd2L3zzPnssmaeqInWHifPvwwa16MyzakPc,23548
7
7
  ripple_down_rules/start-code-server.sh,sha256=otClk7VmDgBOX2TS_cjws6K0UwvgAUJhoA0ugkPCLqQ,949
8
8
  ripple_down_rules/utils.py,sha256=uOa_b3FoDnoTLp84RnMbeSyiTMgREtUOkOImQj8B5HQ,64204
@@ -17,8 +17,8 @@ ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=yp-F8YRWGhj1PLB3
17
17
  ripple_down_rules/user_interface/object_diagram.py,sha256=FEa2HaYR9QmTE6NsOwBvZ0jqmu3DKyg6mig2VE5ZP4Y,4956
18
18
  ripple_down_rules/user_interface/prompt.py,sha256=JceEUGYsd0lIvd-v2y3D3swoo96_C0lxfp3CxM7Vfts,8900
19
19
  ripple_down_rules/user_interface/template_file_creator.py,sha256=kwBbFLyN6Yx2NTIHPSwOoytWgbJDYhgrUOVFw_jkDQ4,13522
20
- ripple_down_rules-0.6.18.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
- ripple_down_rules-0.6.18.dist-info/METADATA,sha256=787ZwHBu2xkOB9XqgRcw4AzwWLmdPba89ozNZtchB0M,48294
22
- ripple_down_rules-0.6.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- ripple_down_rules-0.6.18.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
- ripple_down_rules-0.6.18.dist-info/RECORD,,
20
+ ripple_down_rules-0.6.19.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
21
+ ripple_down_rules-0.6.19.dist-info/METADATA,sha256=rei_pvqow5hMMQOqBDAq-CxM9HTXXrxZ5f-knn-5zms,48294
22
+ ripple_down_rules-0.6.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ ripple_down_rules-0.6.19.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
24
+ ripple_down_rules-0.6.19.dist-info/RECORD,,