From 1cc9aae3bd286a5030b9cb7a3262ba33e06f9638 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Tue, 28 Jan 2025 18:40:07 +1100 Subject: [PATCH] Minor fixups --- yli/distributions.py | 4 ++-- yli/regress.py | 4 ++-- yli/shap.py | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/yli/distributions.py b/yli/distributions.py index ad200a9..c0b79dc 100644 --- a/yli/distributions.py +++ b/yli/distributions.py @@ -1,5 +1,5 @@ # scipy-yli: Helpful SciPy utilities and recipes -# Copyright © 2022 Lee Yingtong Li (RunasSudo) +# Copyright © 2022–2025 Lee Yingtong Li (RunasSudo) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -285,7 +285,7 @@ BETA_ODDSRATIO_CDF_TERMS = [100] beta_oddsratio = betaoddsrat_gen(name='beta_oddsratio', a=0) # a = lower bound of support class transformed_gen(stats.rv_continuous): - """ + r""" Represents a transformation, *Y*, of a "base" random variable, *X* This is a SciPy *stats.rv_continuous* distribution which takes parameters as described below. diff --git a/yli/regress.py b/yli/regress.py index 8f8f352..6a15376 100644 --- a/yli/regress.py +++ b/yli/regress.py @@ -1,5 +1,5 @@ # scipy-yli: Helpful SciPy utilities and recipes -# Copyright © 2022–2023 Lee Yingtong Li (RunasSudo) +# Copyright © 2022–2025 Lee Yingtong Li (RunasSudo) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -494,7 +494,7 @@ class RegressionModel: return out def terms_flat(self): - """ + r""" Iterate over each :class:`SingleTerm` in *self.terms*, recursively stepping through :class:`CategoricalTerm`\ s """ diff --git a/yli/shap.py b/yli/shap.py index 9e1c4b8..6119f46 100644 --- a/yli/shap.py +++ b/yli/shap.py @@ -1,3 +1,19 @@ +# scipy-yli: Helpful SciPy utilities and recipes +# Copyright © 2022–2025 Lee Yingtong Li (RunasSudo) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + import pandas as pd import patsy @@ -29,6 +45,7 @@ class ShapResult: df = check_nan(df, 'omit') # Ensure numeric type for dependent variable + # TODO: Is this step necessary? df[dep], dep_categories = as_numeric(df[dep]) # Convert pandas nullable types for independent variables as this breaks statsmodels @@ -73,6 +90,6 @@ class ShapResult: # https://stackoverflow.com/questions/70461753/shap-the-color-bar-is-not-displayed-in-the-summary-plot ax_colorbar = plt.gcf().axes[-1] ax_colorbar.set_aspect('auto') - ax_colorbar.set_box_aspect(50) + ax_colorbar.set_box_aspect(50) return plt.gcf(), plt.gca()