Categorization Interpretation Example

Categorization Interpretation Example

A visual interpretation for the binary categorization outcome for a single document by looking at the relative contribution of individual words

from __future__ import print_functionimport osfrom sklearn.datasets import fetch_20newsgroupsfrom sklearn.linear_model import LogisticRegressionfrom sklearn.feature_extraction.text import TfidfVectorizerimport matplotlib as mplmpl.use('Agg')import matplotlib.pyplot as pltfrom freediscovery.categorization import binary_sensitivity_analysisfrom freediscovery.interpretation import explain_categorization, _make_cmapnewsgroups = fetch_20newsgroups(subset='train', categories=, remove=('headers', 'footers', 'quotes'))document_id = 312 # the document id we want to visualizevectorizer = TfidfVectorizer(stop_words='english')X = vectorizer.fit_transform(newsgroups.data)clf = LogisticRegression()clf.fit(X, newsgroups.target)repr_proba = 'Predicted: {0}: {{0:.2f}}, {1}: {{1:.2f}}'.format(*newsgroups.target_names)print(repr_proba.format(*clf.predict_proba(X)))print('Actual label :', newsgroups.target_names -->weights = binary_sensitivity_analysis(clf, vectorizer.vocabulary_, X)cmap = _make_cmap(alpha=0.2, filter_ratio=0.15)html, norm = explain_categorization(weights, newsgroups.data, cmap)fig, ax = plt.subplots(1, 1, figsize=(6, 1.2))plt.subplots_adjust(bottom=0.4, top=0.7)cb1 = mpl.colorbar.ColorbarBase(ax, cmap=cmap, norm=norm, orientation='horizontal')cb1.set_label('{} < ----- > {}'.format(*newsgroups.target_names))ax.set_title('Relative word weights', fontsize=12)# visualize the html results in sphinx gallerytmp_dir = os.path.join('..', '..', 'doc', 'python', 'examples')print(os.path.abspath(tmp_dir))if os.path.exists(tmp_dir): with open(os.path.join(tmp_dir, 'out.html'), 'wt') as fh: fh.write(html)


Out:

Predicted: comp.graphics: 0.39, sci.space: 0.61
Actual label : sci.space
/home/ubuntu/FreeDiscovery/doc/python/examples

Can anyone tell me where I might find stereo of planetary and planetary satellite surfaces? GIFs preferred, but any will do. I’m especially interested in stereos of the surfaces of Phobos Deimos, Mars
and the Moon (in that order).
Thanks.

Total running time of the script: ( 0 minutes 13.681 seconds)