Skip to content

Commit

Permalink
Merge 8c4a23d into 06cd707
Browse files Browse the repository at this point in the history
  • Loading branch information
desilinguist committed Mar 9, 2020
2 parents 06cd707 + 8c4a23d commit 90fc45b
Show file tree
Hide file tree
Showing 29 changed files with 1,576 additions and 1,479 deletions.
101 changes: 77 additions & 24 deletions doc/api.rst
Expand Up @@ -6,31 +6,84 @@ The primary method of using RSMTool is via the command-line scripts :ref:`rsmtoo

.. note::

RSMTool v5.7 and older provided the API functions ``metrics_helper``, ``convert_ipynb_to_html``, and ``remove_outliers``. These functions have now been turned into static methods for different classes. If you are using these functions in your code and want to migrate to the new API, you should replace the follwing statements in your code:
RSMTool v5.7 and older provided the API functions ``metrics_helper``, ``convert_ipynb_to_html``, and ``remove_outliers``. These functions have now been turned into static methods for different classes.

In addition, with RSMTool v8.0 onwards, the functions ``agreement``, ``difference_of_standardized_means``, ``get_thumbnail_as_html``, ``parse_json_with_comments``, ``partial_correlations``, ``quadratic_weighted_kappa``, ``show_thumbnail``, ``standardized_mean_difference`` that``utils.py`` have been moved to new locations.

If you are using the above functions in your code and want to migrate to the new API, you should replace the follwing statements in your code:

.. code-block:: python
from rsmtool.analysis import metrics_helper
metrics_helper(...)
from rsmtool.analysis import metrics_helper
metrics_helper(...)
from rsmtool.report import convert_ipynb_to_html
convert_ipynb_to_html(...)
from rsmtool.preprocess import remove_outliers
remove_outliers(...)
from rsmtool.report import convert_ipynb_to_html
convert_ipynb_to_html(...)
from rsmtool.utils import agreement
agreement(...)
from rsmtool.utils import difference_of_standardized_means
difference_of_standardized_means(...)
from rsmtool.utils import partial_correlations
partial_correlations(...)
from rsmtool.preprocess import remove_outliers
remove_outliers(...)
from rsmtool.utils import quadratic_weighted_kappa
quadratic_weighted_kappa(...)
from rsmtool.utils import standardized_mean_difference
standardized_mean_difference(...)
from rsmtool.utils import parse_json_with_comments
parse_json_with_comments(...)
from rsmtool.utils import get_thumbnail_as_html
get_thumbnail_as_html(...)
from rsmtool.utils import show_thumbnail
show_thumbnail(...)
with the following, respectively:

.. code-block:: python
from rsmtool.analyzer import Analyzer
Analyzer.metrics_helper(...)
from rsmtool.analyzer import Analyzer
Analyzer.metrics_helper(...)
from rsmtool.reporter import Reporter
Reporter.convert_ipynb_to_html(...)
from rsmtool.preprocessor import FeaturePreprocessor
FeaturePreprocessor.remove_outliers(...)
from rsmtool.utils.metrics import agreement
agreement(...)
from rsmtool.utils.metrics import difference_of_standardized_means
difference_of_standardized_means(...)
from rsmtool.utils.metrics import partial_correlations
partial_correlations(...)
from rsmtool.utils.metrics import quadratic_weighted_kappa
quadratic_weighted_kappa(...)
from rsmtool.utils.metrics import standardized_mean_difference
standardized_mean_difference(...)
from rsmtool.utils.files import parse_json_with_comments
parse_json_with_comments(...)
from rsmtool.utils.notebook import get_thumbnail_as_html
get_thumbnail_as_html(...)
from rsmtool.utils.notebook import show_thumbnail
show_thumbnail(...)
from rsmtool.reporter import Reporter
Reporter.convert_ipynb_to_html(...)
from rsmtool.preprocessor import FeaturePreprocessor
FeaturePreprocessor.remove_outliers(...)
:mod:`rsmtool` Package
======================
Expand Down Expand Up @@ -125,18 +178,18 @@ From :py:mod:`~rsmtool.utils` Module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. _agreement_api:
.. autofunction:: rsmtool.utils.agreement
.. autofunction:: rsmtool.utils.partial_correlations
.. autofunction:: rsmtool.utils.get_thumbnail_as_html
.. autofunction:: rsmtool.utils.show_thumbnail
.. autofunction:: rsmtool.utils.compute_expected_scores_from_model
.. autofunction:: rsmtool.utils.parse_json_with_comments
.. autofunction:: rsmtool.utils.metrics.agreement
.. _dsm_api:
.. autofunction:: rsmtool.utils.metrics.difference_of_standardized_means
.. autofunction:: rsmtool.utils.metrics.partial_correlations
.. _qwk_api:
.. autofunction:: rsmtool.utils.quadratic_weighted_kappa
.. autofunction:: rsmtool.utils.metrics.quadratic_weighted_kappa
.. _smd_api:
.. autofunction:: rsmtool.utils.standardized_mean_difference
.. _dsm_api:
.. autofunction:: rsmtool.utils.difference_of_standardized_means
.. autofunction:: rsmtool.utils.metrics.standardized_mean_difference
.. autofunction:: rsmtool.utils.metrics.compute_expected_scores_from_model
.. autofunction:: rsmtool.utils.notebook.get_thumbnail_as_html
.. autofunction:: rsmtool.utils.notebook.show_thumbnail
.. autofunction:: rsmtool.utils.files.parse_json_with_comments

From :py:mod:`~rsmtool.writer` Module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
35 changes: 17 additions & 18 deletions rsmtool/__init__.py
Expand Up @@ -30,38 +30,37 @@

from .analyzer import Analyzer

from .convert_feature_json import convert_feature_json_file
from .convert_feature_json import convert_feature_json_file # noqa

from .comparer import Comparer
from .comparer import Comparer # noqa

from .container import DataContainer
from .container import DataContainer # noqa

from .modeler import Modeler
from .modeler import Modeler # noqa

from .preprocessor import FeaturePreprocessor
from .preprocessor import FeaturePreprocessor # noqa

from .reader import DataReader
from .reader import DataReader # noqa

from .reporter import Reporter
from .reporter import Reporter # noqa

from .writer import DataWriter
from .writer import DataWriter # noqa

from .utils import (agreement,
compute_expected_scores_from_model,
get_thumbnail_as_html,
partial_correlations,
show_thumbnail)
from .rsmcompare import run_comparison # noqa

from .rsmcompare import run_comparison
from .rsmeval import run_evaluation # noqa

from .rsmeval import run_evaluation
from .rsmtool import run_experiment # noqa

from .rsmtool import run_experiment
from .rsmpredict import compute_and_save_predictions # noqa

from .rsmpredict import compute_and_save_predictions
from .rsmsummarize import run_summary # noqa

from .rsmsummarize import run_summary
from .utils.metrics import (agreement, # noqa
compute_expected_scores_from_model,
partial_correlations)

from .utils.notebook import get_thumbnail_as_html, show_thumbnail # noqa

# Make sure that DeprecationWarnings are always shown
# within this package unless we are in test mode in
Expand Down
14 changes: 7 additions & 7 deletions rsmtool/analyzer.py
Expand Up @@ -20,13 +20,13 @@
from sklearn.metrics import mean_squared_error
from sklearn.metrics import r2_score

from rsmtool.container import DataContainer
from rsmtool.prmse_utils import compute_prmse
from rsmtool.utils import (agreement,
difference_of_standardized_means,
partial_correlations,
quadratic_weighted_kappa,
standardized_mean_difference)
from .container import DataContainer
from .prmse_utils import compute_prmse
from .utils.metrics import (agreement,
difference_of_standardized_means,
partial_correlations,
quadratic_weighted_kappa,
standardized_mean_difference)


class Analyzer:
Expand Down
4 changes: 2 additions & 2 deletions rsmtool/comparer.py
Expand Up @@ -17,8 +17,8 @@
from scipy.stats import pearsonr
from os.path import exists, join

from rsmtool.reader import DataReader
from rsmtool.utils import get_output_directory_extension
from .reader import DataReader
from .utils.files import get_output_directory_extension


_df_eval_columns_existing_raw = ["N", "h_mean", "h_sd",
Expand Down
23 changes: 12 additions & 11 deletions rsmtool/configuration_parser.py
Expand Up @@ -24,20 +24,21 @@
from pathlib import Path
from ruamel import yaml

from rsmtool import HAS_RSMEXTRA
from rsmtool.utils import parse_json_with_comments
from rsmtool.utils import (DEFAULTS,
CHECK_FIELDS,
LIST_FIELDS,
BOOLEAN_FIELDS,
MODEL_NAME_MAPPING,
FIELD_NAME_MAPPING,
ID_FIELDS,
is_skll_model)

from skll import Learner
from skll.metrics import SCORERS

from . import HAS_RSMEXTRA
from .utils.constants import (DEFAULTS,
CHECK_FIELDS,
LIST_FIELDS,
BOOLEAN_FIELDS,
MODEL_NAME_MAPPING,
FIELD_NAME_MAPPING,
ID_FIELDS)

from .utils.files import is_skll_model, parse_json_with_comments


if HAS_RSMEXTRA:
from rsmextra.settings import (default_feature_subset_file, # noqa
default_feature_sign)
Expand Down
12 changes: 6 additions & 6 deletions rsmtool/modeler.py
Expand Up @@ -24,12 +24,12 @@
from sklearn.linear_model import LassoCV
from skll import FeatureSet, Learner

from rsmtool.analyzer import Analyzer
from rsmtool.utils import compute_expected_scores_from_model, is_skll_model
from rsmtool.preprocessor import FeaturePreprocessor

from rsmtool.container import DataContainer
from rsmtool.writer import DataWriter
from .analyzer import Analyzer
from .container import DataContainer
from .utils.files import is_skll_model
from .utils.metrics import compute_expected_scores_from_model
from .preprocessor import FeaturePreprocessor
from .writer import DataWriter

with warnings.catch_warnings():
warnings.filterwarnings('ignore', category=FutureWarning)
Expand Down
12 changes: 6 additions & 6 deletions rsmtool/notebooks/comparison/header.ipynb
Expand Up @@ -53,12 +53,12 @@
"from rsmtool.reader import DataReader\n",
"from rsmtool.writer import DataWriter\n",
"\n",
"from rsmtool.utils import (float_format_func,\n",
" int_or_float_format_func,\n",
" parse_json_with_comments,\n",
" bold_highlighter,\n",
" color_highlighter,\n",
" show_thumbnail)\n",
"from rsmtool.utils.files import parse_json_with_comments\n",
"from rsmtool.utils.notebook import (float_format_func,\n",
" int_or_float_format_func,\n",
" bold_highlighter,\n",
" color_highlighter,\n",
" show_thumbnail)\n",
"\n",
"from rsmtool.version import VERSION as rsmtool_version"
]
Expand Down
14 changes: 7 additions & 7 deletions rsmtool/notebooks/header.ipynb
Expand Up @@ -48,13 +48,13 @@
"from IPython.display import display, HTML, Image, Javascript, Markdown, SVG\n",
"from rsmtool.reader import DataReader\n",
"from rsmtool.writer import DataWriter\n",
"from rsmtool.utils import (float_format_func,\n",
" int_or_float_format_func,\n",
" compute_subgroup_plot_params,\n",
" parse_json_with_comments,\n",
" bold_highlighter,\n",
" color_highlighter,\n",
" show_thumbnail)\n",
"from rsmtool.utils.files import parse_json_with_comments\n",
"from rsmtool.utils.notebook import (float_format_func,\n",
" int_or_float_format_func,\n",
" compute_subgroup_plot_params,\n",
" bold_highlighter,\n",
" color_highlighter,\n",
" show_thumbnail)\n",
"\n",
"from rsmtool.fairness_utils import (get_fairness_analyses,\n",
" write_fairness_results)\n",
Expand Down
2 changes: 1 addition & 1 deletion rsmtool/notebooks/intermediate_file_paths.ipynb
Expand Up @@ -20,7 +20,7 @@
"metadata": {},
"outputs": [],
"source": [
"from rsmtool.utils import show_files"
"from rsmtool.utils.notebook import show_files"
]
},
{
Expand Down
14 changes: 7 additions & 7 deletions rsmtool/notebooks/summary/header.ipynb
Expand Up @@ -49,13 +49,13 @@
"from IPython import sys_info\n",
"from IPython.display import display, HTML, Image, Javascript, Markdown, SVG\n",
"\n",
"from rsmtool.utils import (float_format_func,\n",
" get_output_directory_extension,\n",
" int_or_float_format_func,\n",
" parse_json_with_comments,\n",
" bold_highlighter,\n",
" color_highlighter,\n",
" show_thumbnail)\n",
"from rsmtool.utils.files import (get_output_directory_extension,\n",
" parse_json_with_comments)\n",
"from rsmtool.utils.notebook import (float_format_func,\n",
" int_or_float_format_func,\n",
" bold_highlighter,\n",
" color_highlighter,\n",
" show_thumbnail)\n",
"\n",
"from rsmtool.reader import DataReader\n",
"from rsmtool.writer import DataWriter\n",
Expand Down
2 changes: 1 addition & 1 deletion rsmtool/notebooks/summary/intermediate_file_paths.ipynb
Expand Up @@ -22,7 +22,7 @@
"metadata": {},
"outputs": [],
"source": [
"from rsmtool.utils import show_files"
"from rsmtool.utils.notebook import show_files"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions rsmtool/preprocessor.py
Expand Up @@ -19,12 +19,12 @@

from numpy.random import RandomState

from rsmtool.reader import DataReader
from rsmtool.container import DataContainer
from rsmtool.reporter import Reporter
from rsmtool.transformer import FeatureTransformer
from rsmtool.utils import convert_to_float
from rsmtool.utils import is_built_in_model, is_skll_model
from .container import DataContainer
from .reader import DataReader
from .reporter import Reporter
from .transformer import FeatureTransformer
from .utils.conversion import convert_to_float
from .utils.files import is_built_in_model, is_skll_model


class FeatureSubsetProcessor:
Expand Down
2 changes: 1 addition & 1 deletion rsmtool/reader.py
Expand Up @@ -19,7 +19,7 @@

import pandas as pd

from rsmtool.container import DataContainer
from .container import DataContainer


def read_jsonlines(filename, converters=None):
Expand Down
6 changes: 3 additions & 3 deletions rsmtool/reporter.py
Expand Up @@ -22,11 +22,11 @@
from traitlets.config import Config
from nbconvert.exporters import HTMLExporter

from rsmtool import HAS_RSMEXTRA
from rsmtool.reader import DataReader
from . import HAS_RSMEXTRA
from .reader import DataReader

if HAS_RSMEXTRA:
from rsmextra.settings import (special_section_list_rsmtool,
from rsmextra.settings import (special_section_list_rsmtool, # noqa
special_section_list_rsmeval,
special_section_list_rsmcompare,
special_section_list_rsmsummarize,
Expand Down

0 comments on commit 90fc45b

Please sign in to comment.