Skip to content

Commit

Permalink
Merge d4b1477 into d358257
Browse files Browse the repository at this point in the history
  • Loading branch information
desilinguist committed May 1, 2020
2 parents d358257 + d4b1477 commit edb6bb1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
6 changes: 1 addition & 5 deletions rsmtool/modeler.py
Expand Up @@ -11,13 +11,13 @@

import logging
import pickle
import warnings

from math import log10, sqrt
from os.path import join

import numpy as np
import pandas as pd
import statsmodels.api as sm

from numpy.random import RandomState
from scipy.optimize import nnls
Expand All @@ -31,10 +31,6 @@
from .preprocessor import FeaturePreprocessor
from .writer import DataWriter

with warnings.catch_warnings():
warnings.filterwarnings('ignore', category=FutureWarning)
import statsmodels.api as sm


class Modeler:
"""
Expand Down
5 changes: 1 addition & 4 deletions rsmtool/notebooks/header.ipynb
Expand Up @@ -41,6 +41,7 @@
"import pandas as pd\n",
"import seaborn as sns\n",
"import scipy.stats as stats\n",
"import statsmodels.api as sm\n",
"from matplotlib import pyplot as plt\n",
"from textwrap import wrap\n",
"\n",
Expand All @@ -61,10 +62,6 @@
"\n",
"from rsmtool.version import VERSION as rsmtool_version\n",
"\n",
"with warnings.catch_warnings():\n",
" warnings.filterwarnings('ignore', category=FutureWarning)\n",
" import statsmodels.api as sm\n",
"\n",
"sns.set_context('notebook')"
]
},
Expand Down
53 changes: 24 additions & 29 deletions rsmtool/notebooks/preprocessed_features.ipynb
Expand Up @@ -50,35 +50,30 @@
" col_wrap = 3\n",
" aspect = 1\n",
"\n",
"# There's a weird deprecation warning that comes from within statsmodels\n",
"# code which is used by seaborn to compute the kernel density estimate.\n",
"# Until statsmodels fixes it, we need to ignore that warning.\n",
"with warnings.catch_warnings():\n",
" warnings.filterwarnings('ignore', category=np.VisibleDeprecationWarning)\n",
" with sns.axes_style('white'):\n",
" g = sns.FacetGrid(col='variable', data=df_train_preproc_melted, col_wrap=col_wrap, \n",
" col_order=column_order, sharex=False, sharey=False, height=height, \n",
" aspect=aspect)\n",
" g.map(sns.distplot, \"value\", color=\"grey\", kde=False)\n",
" for ax, cname in zip(g.axes, g.col_names):\n",
" labels = ax.get_xticks()\n",
" ax.set_xlabel('')\n",
" ax.set_xticklabels(labels, rotation=90)\n",
" plot_title = '\\n'.join(wrap(str(cname), 30))\n",
" ax.set_title(plot_title)\n",
"\n",
" # we want to try to force `tight_layout()`, but if this \n",
" # raises a warning, we don't want the entire notebook to fail\n",
" with warnings.catch_warnings():\n",
" warnings.simplefilter('ignore')\n",
" plt.tight_layout(h_pad=1.0)\n",
"with sns.axes_style('white'):\n",
" g = sns.FacetGrid(col='variable', data=df_train_preproc_melted, col_wrap=col_wrap, \n",
" col_order=column_order, sharex=False, sharey=False, height=height, \n",
" aspect=aspect)\n",
" g.map(sns.distplot, \"value\", color=\"grey\", kde=False)\n",
" for ax, cname in zip(g.axes, g.col_names):\n",
" labels = ax.get_xticks()\n",
" ax.set_xlabel('')\n",
" ax.set_xticklabels(labels, rotation=90)\n",
" plot_title = '\\n'.join(wrap(str(cname), 30))\n",
" ax.set_title(plot_title)\n",
"\n",
" # we want to try to force `tight_layout()`, but if this \n",
" # raises a warning, we don't want the entire notebook to fail\n",
" with warnings.catch_warnings():\n",
" warnings.simplefilter('ignore')\n",
" plt.tight_layout(h_pad=1.0)\n",
"\n",
" imgfile = join(figure_dir, '{}_distrib.svg'.format(experiment_id))\n",
" plt.savefig(imgfile)\n",
" if use_thumbnails:\n",
" show_thumbnail(imgfile, next(id_generator))\n",
" else:\n",
" plt.show()"
" imgfile = join(figure_dir, '{}_distrib.svg'.format(experiment_id))\n",
" plt.savefig(imgfile)\n",
" if use_thumbnails:\n",
" show_thumbnail(imgfile, next(id_generator))\n",
" else:\n",
" plt.show()"
]
},
{
Expand Down Expand Up @@ -338,7 +333,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
"version": "3.7.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit edb6bb1

Please sign in to comment.