xdat
Advanced tools
+1
-1
| Metadata-Version: 2.4 | ||
| Name: xdat | ||
| Version: 0.1.297 | ||
| Version: 0.1.298 | ||
| Summary: eXtended Data Analysis Toolkit | ||
@@ -5,0 +5,0 @@ Home-page: https://bitbucket.org/hermetric/xdat/ |
| Metadata-Version: 2.4 | ||
| Name: xdat | ||
| Version: 0.1.297 | ||
| Version: 0.1.298 | ||
| Summary: eXtended Data Analysis Toolkit | ||
@@ -5,0 +5,0 @@ Home-page: https://bitbucket.org/hermetric/xdat/ |
+1
-1
@@ -1,1 +0,1 @@ | ||
| 0.1.297 | ||
| 0.1.298 |
+9
-2
@@ -228,3 +228,3 @@ from contextlib import contextmanager | ||
| def plot_feature_importances(folds, use_shap=False, title='', top_k=None, show=True, as_xpptx=None, also_text=False): | ||
| def plot_feature_importances(folds, use_shap=False, title='', desc='', top_k=None, show=True, as_xpptx=None, also_text=False): | ||
| df = xproblem.calc_feature_importances(folds, use_shap=use_shap, flat=True) | ||
@@ -249,3 +249,3 @@ if df is None: | ||
| post_plot(xlim=[0, None], show=show, as_xpptx=as_xpptx) | ||
| post_plot(xlim=[0, None], show=show, title=title, desc=desc, as_xpptx=as_xpptx) | ||
@@ -1538,2 +1538,9 @@ if also_text: | ||
| hdi_probs = sorted(hdi_probs) | ||
| if not slide_note: | ||
| prob_text = ", ".join([f"{100*p:.0f}%" for p in hdi_probs]) | ||
| slide_note = f"The shaded regions hold {prob_text} of the data.\n\n" | ||
| if x_kde: | ||
| slide_note += "Because the x-axis is continuous (not binned), the values are merged in a way that is similar to a moving average.\n\n" | ||
| alpha_step = alpha / len(hdi_probs) | ||
@@ -1540,0 +1547,0 @@ |
+13
-5
@@ -352,3 +352,11 @@ """ | ||
| _TOKENIZER = re.compile( | ||
| r"(\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|`[^`]+`|\*[^*]+\*|_[^_]+_|https?://\S+|www\.\S+)" | ||
| r"(" | ||
| r"\[[^\]]+\]\([^)]+\)" # [text](url) | ||
| r"|\*\*[^*\n]+\*\*" # **bold** | ||
| r"|`[^`\n]+`" # `code` | ||
| r"|(?<!\w)\*(?!\s)[^*\n]+?\*(?!\w)" # *italic* (not inside word) | ||
| r"|(?<!\w)_(?!\s|_)[^_\n]+?_(?!\w)" # _italic_ (not inside word) | ||
| r"|https?://[^\s<>()\[\]{}\"']+[^\s<>()\[\]{}\"'.,;:!?]" # URL | ||
| r"|www\.[^\s<>()\[\]{}\"']+[^\s<>()\[\]{}\"'.,;:!?]" # URL | ||
| r")" | ||
| ) | ||
@@ -391,3 +399,3 @@ | ||
| # links | ||
| if re.search(r"\[[^\]]+\]\([^)]+\)", s): | ||
| if re.search(r"\[[^\]]+\]\([^\n]+\)", s): | ||
| return True | ||
@@ -578,6 +586,6 @@ # bold | ||
| self._add_run(paragraph, tok[1:-1], italic=True, bold=force_bold, underline=force_underline) | ||
| elif tok.startswith("_"): | ||
| elif tok.startswith("_") and re.fullmatch(r"(?<!\w)_(?!\s|_)[^_\n]+?_(?!\w)", tok): | ||
| self._add_run(paragraph, tok[1:-1], italic=True, bold=force_bold, underline=force_underline) | ||
| else: # bare URL | ||
| self._add_run(paragraph, tok, link=tok, bold=force_bold, underline=True or force_underline) | ||
| else: | ||
| self._add_run(paragraph, tok, bold=force_bold, underline=force_underline) | ||
@@ -584,0 +592,0 @@ pos = m.end() |
+24
-1
@@ -471,2 +471,25 @@ import numpy as np | ||
| def x_make_shap_explainer(model, X, background_size=100): | ||
| """ | ||
| Create an appropriate SHAP explainer for the given model. | ||
| """ | ||
| try: | ||
| explainer = shap.Explainer(model, X) | ||
| return explainer | ||
| except TypeError: | ||
| pass | ||
| # Black-box fallback → MUST reduce background | ||
| background = shap.kmeans(X, min(len(X), background_size)) | ||
| if hasattr(model, "predict_proba"): | ||
| return shap.KernelExplainer(model.predict_proba, background) | ||
| if hasattr(model, "predict"): | ||
| return shap.KernelExplainer(model.predict, background) | ||
| raise TypeError(f"Unsupported model type: {type(model)}") | ||
| def calc_feature_importances(folds, flat=False, use_shap=False): | ||
@@ -504,3 +527,3 @@ """ | ||
| explainer = shap.Explainer(estimator, X_in) | ||
| explainer = x_make_shap_explainer(estimator, X_in) | ||
| shap_values = explainer(X_in) | ||
@@ -507,0 +530,0 @@ |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
932143
0.15%9047
0.32%