Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisibleDeprecationWarning Exception #174

Open
fccoelho opened this issue Jul 13, 2024 · 2 comments · May be fixed by #178
Open

VisibleDeprecationWarning Exception #174

fccoelho opened this issue Jul 13, 2024 · 2 comments · May be fixed by #178

Comments

@fccoelho
Copy link

When I try to analyze a dataframe I get the following exception:

AttributeError                            Traceback (most recent call last)
Cell In[7], line 1
----> 1 sweetviz.analyze(df)

File ~/Documentos/Projects_Software/reg/.venv/lib/python3.12/site-packages/sweetviz/sv_public.py:12, in analyze(source, target_feat, feat_cfg, pairwise_analysis)
      8 def analyze(source: Union[pd.DataFrame, Tuple[pd.DataFrame, str]],
      9             target_feat: str = None,
     10             feat_cfg: FeatureConfig = None,
     11             pairwise_analysis: str = 'auto'):
---> 12     report = sweetviz.DataframeReport(source, target_feat, None,
     13                                       pairwise_analysis, feat_cfg)
     14     return report

File ~/Documentos/Projects_Software/reg/.venv/lib/python3.12/site-packages/sweetviz/dataframe_report.py:277, in DataframeReport.__init__(self, source, target_feature_name, compare, pairwise_analysis, fc, verbosity)
    274 for f in features_to_process:
    275     # start = time.perf_counter()
    276     self.progress_bar.set_description_str(f"Feature: {f.source.name}")
--> 277     self._features[f.source.name] = sa.analyze_feature_to_dictionary(f)
    278     self.progress_bar.update(1)
    279     # print(f"DONE FEATURE------> {f.source.name}"
    280     #       f" {(time.perf_counter() - start):.2f}   {self._features[f.source.name]['type']}")
    281 # self.progress_bar.set_description_str('[FEATURES DONE]')
    282 # self.progress_bar.close()
    283 
    284 # Wrap up summary

File ~/Documentos/Projects_Software/reg/.venv/lib/python3.12/site-packages/sweetviz/series_analyzer.py:142, in analyze_feature_to_dictionary(to_process)
    140 # Perform full analysis on source/compare/target
    141 if returned_feature_dict["type"] == FeatureType.TYPE_NUM:
--> 142     sweetviz.series_analyzer_numeric.analyze(to_process, returned_feature_dict)
    143 elif returned_feature_dict["type"] == FeatureType.TYPE_CAT:
    144     sweetviz.series_analyzer_cat.analyze(to_process, returned_feature_dict)

File ~/Documentos/Projects_Software/reg/.venv/lib/python3.12/site-packages/sweetviz/series_analyzer_numeric.py:102, in analyze(to_process, feature_dict)
     98     do_stats_numeric(to_process.compare, compare_dict)
    100 do_detail_numeric(to_process.source, to_process.source_counts, to_process.compare_counts, feature_dict)
--> 102 feature_dict["minigraph"] = GraphNumeric("mini", to_process)
    103 feature_dict["detail_graphs"] = list()
    104 for num_bins in [0, 5, 15, 30]:

File ~/Documentos/Projects_Software/reg/.venv/lib/python3.12/site-packages/sweetviz/graph_numeric.py:71, in GraphNumeric.__init__(self, which_graph, to_process)
     67     normalizing_weights = norm_source
     69 gap_percent = config["Graphs"].getfloat("summary_graph_categorical_gap")
---> 71 warnings.filterwarnings('ignore', category=np.VisibleDeprecationWarning)
     72 self.hist_specs = axs.hist(plot_data, weights = normalizing_weights, bins=self.num_bins, \
     73                            rwidth = (100.0 - gap_percent) / 100.0)
     74 warnings.filterwarnings('once', category=np.VisibleDeprecationWarning)

File ~/Documentos/Projects_Software/reg/.venv/lib/python3.12/site-packages/numpy/__init__.py:410, in __getattr__(attr)
    407     import numpy.char as char
    408     return char.chararray
--> 410 raise AttributeError("module {!r} has no attribute "
    411                      "{!r}".format(__name__, attr))

AttributeError: module 'numpy' has no attribute 'VisibleDeprecationWarning'

Is there any way to workaround this bug?

@whentheworldfallsapart
Copy link

This seems to likely be an issue with changes in numpy 2.0.
Work arounds:

  1. try downgrading numpy <2.0
  2. comment out lines 71 and 74 in graph_numeric.py as VisibleDeprecationWarning as they aren't critical (this is what i did)
  3. VisibleDeprecationWarning is in exceptions https://numpy.org/doc/stable/reference/generated/numpy.exceptions.VisibleDeprecationWarning.html

@jwpark0921
Copy link

jwpark0921 commented Aug 5, 2024

This is because the VisibleDeprecationWarning attribute has been removed from the main namespace since numpy 2.0.
As whentheworldfallsapart said, downgrading the numpy version is the fastest solution.
However, ultimately, it seems necessary to patch np.VisibleDeprecationWarning to np.exceptions.VisibleDeprecationWarning in graph_numeric.py:71 and 74.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants