diff --git a/doc/conf.py b/doc/conf.py index d96f4eb8..b186c301 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -25,7 +25,11 @@ sys.path.insert(0, curr_path) import mock -MOCK_MODULES = ['numpy', 'scipy', 'scipy.sparse', 'sklearn', 'sklearn.preprocessing', 'sklearn.linear_model', 'matplotlib'] +MOCK_MODULES = ['numpy', 'scipy', 'scipy.sparse', 'sklearn', + 'sklearn.preprocessing', 'sklearn.linear_model', 'matplotlib', + 'sklearn.datasets', 'sklearn.ensemble', 'sklearn.cross_validation', + 'sklearn.feature_extraction', 'sklearn.feature_extraction.text', + 'sklearn.metrics', 'sklearn.naive_bayes', 'sklearn.pipeline'] for mod_name in MOCK_MODULES: sys.modules[mod_name] = mock.Mock() diff --git a/doc/lime.rst b/doc/lime.rst index ee30dc36..8648c011 100644 --- a/doc/lime.rst +++ b/doc/lime.rst @@ -1,46 +1,77 @@ lime package ============ +Subpackages +----------- + +.. toctree:: + + lime.tests + Submodules ---------- -lime.lime_tabular module ------------------------- +lime\.discretize module +----------------------- -.. automodule:: lime.lime_tabular +.. automodule:: lime.discretize :members: :undoc-members: :show-inheritance: -lime.lime_text module ---------------------- +lime\.exceptions module +----------------------- -.. automodule:: lime.lime_text +.. automodule:: lime.exceptions :members: :undoc-members: :show-inheritance: -lime.discretize module ----------------------- +lime\.explanation module +------------------------ -.. automodule:: lime.discretize +.. automodule:: lime.explanation :members: :undoc-members: :show-inheritance: -lime.explanation module +lime\.lime\_base module ----------------------- -.. automodule:: lime.explanation +.. automodule:: lime.lime_base :members: :undoc-members: :show-inheritance: -lime.lime_base module ---------------------- +lime\.lime\_image module +------------------------ -.. automodule:: lime.lime_base +.. automodule:: lime.lime_image + :members: + :undoc-members: + :show-inheritance: + +lime\.lime\_tabular module +-------------------------- + +.. automodule:: lime.lime_tabular :members: :undoc-members: :show-inheritance: +lime\.lime\_text module +----------------------- + +.. automodule:: lime.lime_text + :members: + :undoc-members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: lime + :members: + :undoc-members: + :show-inheritance: diff --git a/lime/lime_tabular.py b/lime/lime_tabular.py index 5be95a15..f87323c1 100644 --- a/lime/lime_tabular.py +++ b/lime/lime_tabular.py @@ -123,7 +123,7 @@ def __init__(self, categorical_names[x][y] represents the name of the yth value of column x. kernel_width: kernel width for the exponential kernel. - If None, defaults to sqrt(number of columns) * 0.75 + If None, defaults to sqrt (number of columns) * 0.75 verbose: if true, print local prediction values from linear model class_names: list of class names, ordered according to whatever the classifier is using. If not present, class names will be '0', @@ -229,8 +229,8 @@ def explain_instance(self, function that takes a numpy array and outputs prediction probabilities. For regressors, this takes a numpy array and returns the predictions. For ScikitClassifiers, this is - `classifier.predict_proba()`. For ScikitRegressors, this - is `regressor.predict()`. + `classifier.predict_proba()`. For ScikitRegressors, this + is `regressor.predict()`. labels: iterable with labels to be explained. top_labels: if not None, ignore labels and produce explanations for the K labels with highest prediction probabilities, where K is @@ -239,8 +239,8 @@ def explain_instance(self, num_samples: size of the neighborhood to learn the linear model distance_metric: the distance metric to use for weights. model_regressor: sklearn regressor to use in explanation. Defaults - to Ridge regression in LimeBase. Must have model_regressor.coef_ - and 'sample_weight' as a parameter to model_regressor.fit() + to Ridge regression in LimeBase. Must have model_regressor.coef_ + and 'sample_weight' as a parameter to model_regressor.fit() Returns: An Explanation object (see explanation.py) with the corresponding diff --git a/lime/tests/test_lime_tabular.py b/lime/tests/test_lime_tabular.py index 84059a2d..5e6bd33f 100644 --- a/lime/tests/test_lime_tabular.py +++ b/lime/tests/test_lime_tabular.py @@ -1,6 +1,10 @@ import unittest import numpy as np +import sklearn +import sklearn.datasets +import sklearn.ensemble +import sklearn.linear_model from sklearn.datasets import load_iris, make_classification from sklearn.ensemble import RandomForestClassifier from sklearn.linear_model import Lasso diff --git a/lime/tests/test_lime_text.py b/lime/tests/test_lime_text.py index 71e0a060..db8c382f 100644 --- a/lime/tests/test_lime_text.py +++ b/lime/tests/test_lime_text.py @@ -1,5 +1,6 @@ import unittest +import sklearn from sklearn.datasets import fetch_20newsgroups from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.linear_model import Lasso