Minor fixups
This commit is contained in:
parent
b7a66849ff
commit
1cc9aae3bd
@ -1,5 +1,5 @@
|
|||||||
# scipy-yli: Helpful SciPy utilities and recipes
|
# 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
|
# 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
|
# 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
|
beta_oddsratio = betaoddsrat_gen(name='beta_oddsratio', a=0) # a = lower bound of support
|
||||||
|
|
||||||
class transformed_gen(stats.rv_continuous):
|
class transformed_gen(stats.rv_continuous):
|
||||||
"""
|
r"""
|
||||||
Represents a transformation, *Y*, of a "base" random variable, *X*
|
Represents a transformation, *Y*, of a "base" random variable, *X*
|
||||||
|
|
||||||
This is a SciPy *stats.rv_continuous* distribution which takes parameters as described below.
|
This is a SciPy *stats.rv_continuous* distribution which takes parameters as described below.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# scipy-yli: Helpful SciPy utilities and recipes
|
# 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
|
# 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
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -494,7 +494,7 @@ class RegressionModel:
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
def terms_flat(self):
|
def terms_flat(self):
|
||||||
"""
|
r"""
|
||||||
Iterate over each :class:`SingleTerm` in *self.terms*, recursively stepping through :class:`CategoricalTerm`\ s
|
Iterate over each :class:`SingleTerm` in *self.terms*, recursively stepping through :class:`CategoricalTerm`\ s
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
19
yli/shap.py
19
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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import patsy
|
import patsy
|
||||||
|
|
||||||
@ -29,6 +45,7 @@ class ShapResult:
|
|||||||
df = check_nan(df, 'omit')
|
df = check_nan(df, 'omit')
|
||||||
|
|
||||||
# Ensure numeric type for dependent variable
|
# Ensure numeric type for dependent variable
|
||||||
|
# TODO: Is this step necessary?
|
||||||
df[dep], dep_categories = as_numeric(df[dep])
|
df[dep], dep_categories = as_numeric(df[dep])
|
||||||
|
|
||||||
# Convert pandas nullable types for independent variables as this breaks statsmodels
|
# 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
|
# https://stackoverflow.com/questions/70461753/shap-the-color-bar-is-not-displayed-in-the-summary-plot
|
||||||
ax_colorbar = plt.gcf().axes[-1]
|
ax_colorbar = plt.gcf().axes[-1]
|
||||||
ax_colorbar.set_aspect('auto')
|
ax_colorbar.set_aspect('auto')
|
||||||
ax_colorbar.set_box_aspect(50)
|
ax_colorbar.set_box_aspect(50)
|
||||||
|
|
||||||
return plt.gcf(), plt.gca()
|
return plt.gcf(), plt.gca()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user