-
Notifications
You must be signed in to change notification settings - Fork 182
/
data.html
155 lines (132 loc) · 9.39 KB
/
data.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dice_ml.data — DiCE 0.11 documentation</title>
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/sphinx_highlight.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home"> DiCE
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Getting Started:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../readme.html">Diverse Counterfactual Explanations (DiCE) for ML</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Notebooks:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/DiCE_getting_started.html">Quick introduction to generating counterfactual explanations using DiCE</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/DiCE_feature_importances.html">Estimating local and global feature importance scores using DiCE</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/DiCE_multiclass_classification_and_regression.html">Generating counterfactuals for multi-class classification and regression models</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/DiCE_multiclass_classification_and_regression.html#Regression">Regression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/DiCE_model_agnostic_CFs.html">Generating counterfactual explanations with any ML model</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/DiCE_with_private_data.html">Generating counterfactual explanations without access to training data</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../notebooks/DiCE_with_advanced_options.html">Advanced options to customize Counterfactual Explanations</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">Package:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../dice_ml.html">dice_ml package</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">DiCE</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home"></a> »</li>
<li><a href="../index.html">Module code</a> »</li>
<li>dice_ml.data</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<h1>Source code for dice_ml.data</h1><div class="highlight"><pre>
<span></span><span class="sd">"""Module pointing to different implementations of Data class</span>
<span class="sd">DiCE requires only few parameters about the data such as the range of continuous</span>
<span class="sd">features and the levels of categorical features. Hence, DiCE can be used for a</span>
<span class="sd">private data whose meta data are only available (such as the feature names and</span>
<span class="sd">range/levels of different features) by specifying appropriate parameters.</span>
<span class="sd">"""</span>
<span class="kn">from</span> <span class="nn">dice_ml.data_interfaces.base_data_interface</span> <span class="kn">import</span> <span class="n">_BaseData</span>
<div class="viewcode-block" id="Data"><a class="viewcode-back" href="../../dice_ml.html#dice_ml.data.Data">[docs]</a><span class="k">class</span> <span class="nc">Data</span><span class="p">(</span><span class="n">_BaseData</span><span class="p">):</span>
<span class="w"> </span><span class="sd">"""Class containing all required information about the data for DiCE."""</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">params</span><span class="p">):</span>
<span class="w"> </span><span class="sd">"""Init method</span>
<span class="sd"> :param **params: a dictionary of required parameters.</span>
<span class="sd"> """</span>
<span class="bp">self</span><span class="o">.</span><span class="n">decide_implementation_type</span><span class="p">(</span><span class="n">params</span><span class="p">)</span>
<div class="viewcode-block" id="Data.decide_implementation_type"><a class="viewcode-back" href="../../dice_ml.html#dice_ml.data.Data.decide_implementation_type">[docs]</a> <span class="k">def</span> <span class="nf">decide_implementation_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">params</span><span class="p">):</span>
<span class="w"> </span><span class="sd">"""Decides if the Data class is for public or private data."""</span>
<span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span> <span class="o">=</span> <span class="n">decide</span><span class="p">(</span><span class="n">params</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">params</span><span class="p">)</span></div></div>
<div class="viewcode-block" id="decide"><a class="viewcode-back" href="../../dice_ml.html#dice_ml.data.decide">[docs]</a><span class="k">def</span> <span class="nf">decide</span><span class="p">(</span><span class="n">params</span><span class="p">):</span>
<span class="w"> </span><span class="sd">"""Decides if the Data class is for public or private data.</span>
<span class="sd"> To add new implementations of Data, add the class in data_interfaces</span>
<span class="sd"> subpackage and import-and-return the class in an elif loop as shown</span>
<span class="sd"> in the below method.</span>
<span class="sd"> """</span>
<span class="k">if</span> <span class="s1">'dataframe'</span> <span class="ow">in</span> <span class="n">params</span><span class="p">:</span>
<span class="c1"># if params contain a Pandas dataframe, then use PublicData class</span>
<span class="kn">from</span> <span class="nn">dice_ml.data_interfaces.public_data_interface</span> <span class="kn">import</span> <span class="n">PublicData</span>
<span class="k">return</span> <span class="n">PublicData</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># use PrivateData if only meta data is provided</span>
<span class="kn">from</span> <span class="nn">dice_ml.data_interfaces.private_data_interface</span> <span class="kn">import</span> <span class="n">PrivateData</span>
<span class="k">return</span> <span class="n">PrivateData</span></div>
</pre></div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>© Copyright 2020, Ramaravind, Amit, Chenhao.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>