MLVisualizationTools 0.7.0__py3-none-any.whl → 0.7.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,4 +7,5 @@ import MLVisualizationTools.modelinterface as Interfaces
7
7
  import MLVisualizationTools.colorizers as Colorizers
8
8
  import MLVisualizationTools.graphinterface as Graphs
9
9
  import MLVisualizationTools.datainterface as DataInterfaces
10
- import MLVisualizationTools.types as types
10
+ import MLVisualizationTools.types as types
11
+ import MLVisualizationTools.removefeature as RemoveFeature
@@ -88,7 +88,7 @@ def binary(data: GraphData, highcontrast:bool=True, truecolor: Optional[str] = N
88
88
  for d in locations:
89
89
  df = d.dataframe
90
90
 
91
- df.loc[df[data.outputkey] > cutoff, data.colorkey] = truecolor
91
+ df[data.colorkey] = truecolor
92
92
  df.loc[df[data.outputkey] <= cutoff, data.colorkey] = falsecolor
93
93
  d.colorized = ColorizerModes.Binary
94
94
  d.truecolor.color = truecolor
@@ -0,0 +1,25 @@
1
+ from MLVisualizationTools import RemoveFeature
2
+ from MLVisualizationTools.backend import fileloader
3
+ import pandas as pd
4
+ import os
5
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' #stops agressive error message printing
6
+ from tensorflow import keras
7
+
8
+ def main(verbose=True):
9
+ """Run the demo. Disable show for testing purposes."""
10
+ model = keras.models.load_model(fileloader('examples/Models/titanicmodel'))
11
+ df: pd.DataFrame = pd.read_csv(fileloader('examples/Datasets/Titanic/train.csv'))
12
+
13
+ header = list(df.columns)
14
+ header.remove("Survived")
15
+
16
+ X = df[header]
17
+ Y = df["Survived"]
18
+
19
+ RemoveFeature.testFeatureRemoval(model, X, Y, verbose=verbose)
20
+
21
+ print("This demo shows remove feature analysis.")
22
+ print("To run the demo, call Demo.main()")
23
+
24
+ if __name__ == "__main__":
25
+ main(verbose=True)
@@ -0,0 +1,42 @@
1
+ """
2
+ Remove Feature
3
+
4
+ Tests if a feature significantly effects evaluation results in a model - useful for limiting size of a neural network.
5
+ """
6
+
7
+ def testFeatureRemoval(model, X, Y, thresh=0.99, verbose=True):
8
+ """
9
+ Tests if removing a feature effects evaluation results.
10
+ Returns a list of features to remove
11
+
12
+ :param model: A ML model, must support .evaluate() calls
13
+ :param X: A pandas dataframe with X features - each column should have a name
14
+ :param Y: A pandas dataframe with Y features
15
+ :param thresh: is accuracy >= baseline * thresh , suggest removing feature
16
+ :param verbose: print info during test
17
+ """
18
+
19
+ baseline_accuracy = model.evaluate(X.values, Y.values)[1]
20
+ if verbose:
21
+ print("Model baseline accuracy:", baseline_accuracy)
22
+
23
+ rm_list = []
24
+
25
+ header = list(X.columns)
26
+ for c in header:
27
+ t_X = X.copy(deep=True)
28
+ t_X[c] = t_X[c].mean()
29
+ accuracy = model.evaluate(t_X.values, Y.values)[1]
30
+
31
+ if accuracy >= baseline_accuracy * thresh:
32
+ print("Without", c, "accuracy:", accuracy)
33
+ rm_list.append(c)
34
+
35
+ elif verbose:
36
+ print("Without", c, "accuracy:", accuracy)
37
+
38
+ print("Suggest removing:", rm_list)
39
+
40
+ return rm_list
41
+
42
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MLVisualizationTools
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: A set of functions and demos to make machine learning projects easier to understand through effective visualizations.
5
5
  Home-page: https://github.com/RobertJN64/MLVisualizationTools
6
6
  Author: Robert Nies
@@ -21,7 +21,7 @@ Provides-Extra: dash
21
21
  Requires-Dist: dash ; extra == 'dash'
22
22
  Requires-Dist: flask ; extra == 'dash'
23
23
  Requires-Dist: plotly ; extra == 'dash'
24
- Requires-Dist: dash-bootstrap-components (>=1.0.0) ; extra == 'dash'
24
+ Requires-Dist: dash-bootstrap-components >=1.0.0 ; extra == 'dash'
25
25
  Requires-Dist: dash-tour-component ; extra == 'dash'
26
26
  Provides-Extra: dash-notebook
27
27
  Requires-Dist: MLVisualizationTools[dash] ; extra == 'dash-notebook'
@@ -88,7 +88,7 @@ App.visualize(model, data)
88
88
  MLVisualizationTools connects a variety of smaller functions.
89
89
 
90
90
  Steps:
91
- 1. Keras Model and Dataframe with features
91
+ 1. Start with a ML Model and Dataframe with features
92
92
  2. Analyzer
93
93
  3. Interface / Interface Raw (if you don't have a dataframe)
94
94
  4. Colorizers (optional)
@@ -96,7 +96,7 @@ Steps:
96
96
  6. Colorize data points (Optional)
97
97
  7. Graphs
98
98
 
99
- Analyzers take a keras model and return information about the inputs
99
+ Analyzers take a ml model and return information about the inputs
100
100
  such as which ones have high variance.
101
101
 
102
102
  Interfaces take parameters and construct a multidimensional grid
@@ -149,6 +149,25 @@ notebooks
149
149
  See [MLVisualizationTools/Examples](/MLVisualizationTools/examples) for more examples.
150
150
  Use example.main() to run the examples and set parameters such as themes.
151
151
 
152
+ ## Tensorflow Compatibility
153
+
154
+ MLVisualizationTools is distributed with a pretrained tensorflow model
155
+ to make running examples quick and easy. It is not needed for main library functions.
156
+
157
+ For version 2.0 through 2.4, we load a v2.0 model.
158
+ For version 2.5+ we load a v2.5 model.
159
+
160
+ If this causes compatibility issues you can still use the main library on your models.
161
+ If you need an example model, retrain it with
162
+ [TrainTitanicModel.py](/MLVisualizationTools/examples/TrainTitanicModel.py)
163
+
164
+ ## scikit-learn Compatibility
165
+
166
+ See [SklearnDemo.py](/MLVisualizationTools/examples/SklearnDemo.py)
167
+
168
+ Sklearn can be used exactly like TF because it has the same `.predict(X) -> Y` interface.
169
+
170
+
152
171
  ## Support for more ML Libraries
153
172
 
154
173
  We support any ML library that has a `predict()` call that takes
@@ -166,20 +185,9 @@ class ModelWrapper:
166
185
  ... #Do whatever code you need here
167
186
  ```
168
187
 
169
- ## Tensorflow Compatibility
170
-
171
- MLVisualizationTools is distributed with a pretrained tensorflow model
172
- to make running examples quick and easy. It is not needed for main library functions.
173
-
174
- For version 2.0 through 2.4, we load a v2.0 model.
175
- For version 2.5+ we load a v2.5 model.
176
-
177
- If this causes compatibility issues you can still use the main library on your models.
178
- If you need an example model, retrain it with
179
- [TrainTitanicModel.py](/MLVisualizationTools/examples/TrainTitanicModel.py)
180
-
181
- ## scikit-learn Compatibility
188
+ ## Remove Feature Testing
182
189
 
183
- See [SklearnDemo.py](/MLVisualizationTools/examples/SklearnDemo.py)
190
+ See [RemoveFeatureDemo.py](/MLVisualizationTools/examples/RemoveFeatureDemo.py)
184
191
 
185
- Sklearn can be used exactly like TF because it has the same `.predict(X, Y)` interface.
192
+ Tests if features can be removed from dataset without significantly affecting accuracy.
193
+ Replaces each dataset column with mean and compares to baseline accuracy.
@@ -1,11 +1,12 @@
1
- MLVisualizationTools/__init__.py,sha256=wHDrA4qqsOehDO6AGoiacGUkcNT5vXH0BM2r4X-jUD4,448
1
+ MLVisualizationTools/__init__.py,sha256=PA5zC9G6I4F6Scu4FYvJqvYdWujc2pxMkX8MNhkfhRU,507
2
2
  MLVisualizationTools/backend.py,sha256=b-f0eVZTKtbdowjnxj0osg3gbunnVT5-3BnmpRFP_hU,4429
3
- MLVisualizationTools/colorizers.py,sha256=jx3og-AXAuGPY_dzsb09vt8AP4q5VLGA26GR43ip9YE,3651
3
+ MLVisualizationTools/colorizers.py,sha256=ypcFFE7XYTk2a3huMEb4QYvBhrnIX42wK8SMtjWy5Qw,3618
4
4
  MLVisualizationTools/dashbackend.py,sha256=hhoobhuU45v7N1jlAY6L7zG2qu-DHMrKn6QXwPzqseY,3238
5
5
  MLVisualizationTools/datainterface.py,sha256=-4aY_J0BEgDGfejRxadn2gbB2xSVyLcNOaup6PsHTCw,5210
6
6
  MLVisualizationTools/graphinterface.py,sha256=shCiM8h0kQnep5lt3xmahmdxoI6QglrrPYsi9Vypwqg,10808
7
7
  MLVisualizationTools/modelanalytics.py,sha256=tgSf0cYG2ERmC8iOctmc5u7RVmXikT1uaYiB4gnFE0s,3183
8
8
  MLVisualizationTools/modelinterface.py,sha256=Wzxm-_G9EVQoojPKMPxmDAdonijABy9N081pPbeFdKg,7209
9
+ MLVisualizationTools/removefeature.py,sha256=2VMcX5-JwTxR6kz_Jr6pUDz_DdhIY8VixJd8vtRUSkg,1249
9
10
  MLVisualizationTools/types.py,sha256=uG6U5rAnedinOFKeLXWfXEKzhl9ZRGspPQPgjd1PIvw,333
10
11
  MLVisualizationTools/examples/AnimationDemo.py,sha256=0-COJDwDBPfyCRvr5ABlT6SrQyNbYbS_niZj6Z0iR18,1504
11
12
  MLVisualizationTools/examples/DashDemo.py,sha256=rqQzwqHoijIwOmgTe4ip_DY3pGLHyZfLx4iJ3HjxuaQ,1154
@@ -14,6 +15,7 @@ MLVisualizationTools/examples/DashNotebookDemo.py,sha256=hvO1Pk2Qw5DahIgH2oXMlJ6
14
15
  MLVisualizationTools/examples/DataOverlayDemo.py,sha256=alO-jzgseF3TguxxK8A59_T1o0VxKMJXbdPE2QVqZNg,2529
15
16
  MLVisualizationTools/examples/Demo.py,sha256=aV1BspW0wG87MXaV2SxbHDa23Hbwk0JPF_vZO7NNUeU,1420
16
17
  MLVisualizationTools/examples/MatplotlibDemo.py,sha256=HJsRI0pxM9ik41GQh-M19gEfKay5FNXz8wN99g_esMw,1398
18
+ MLVisualizationTools/examples/RemoveFeatureDemo.py,sha256=oFpTxvnzWsedPxdc8arXSX0JBuky64CIq0uO8_1rFbs,805
17
19
  MLVisualizationTools/examples/SklearnDemo.py,sha256=X9IlM9ccS0GB0m2dZW2XnVVSR5rT9dEClrGG_QaXas8,1453
18
20
  MLVisualizationTools/examples/TrainTitanicModel.py,sha256=kqSNNguCQIYThW7kXVOnX5zVx70YmgBs3lmi1TbwMT8,1799
19
21
  MLVisualizationTools/examples/Datasets/Titanic/TitanicDemoPreprocess.py,sha256=vnhT3mQhpKAKRIFt04QWSrTLgAkqnULAM9FPe11AiGE,958
@@ -31,8 +33,8 @@ MLVisualizationTools/express/DashModelVisualizer.py,sha256=ZMmsO8PxQ4KP9eI9XXo_s
31
33
  MLVisualizationTools/express/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
34
  MLVisualizationTools/theme_assets/dark_assets/darktheme.css,sha256=oUDm4B38eZZdCgW19eaikIFtPCYy6lW3xMrHH62NIKs,9473
33
35
  MLVisualizationTools/theme_assets/light_assets/lighttheme.css,sha256=WZtoP8pxv2EX_L9UMt99XuL-glzLlc_oBI2P-QK7AyY,82
34
- MLVisualizationTools-0.7.0.dist-info/LICENSE,sha256=_51uDCYkBuFe8igxf5GL1MeYy_U9yux8fwvXLRHDOdM,1050
35
- MLVisualizationTools-0.7.0.dist-info/METADATA,sha256=BP90HSeq3MqQ4q2lqZpMSkCLaF8DjHD360uyFRbQzHo,6264
36
- MLVisualizationTools-0.7.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
37
- MLVisualizationTools-0.7.0.dist-info/top_level.txt,sha256=lOdCZd0Sb0J6Cf_--kCquNmij5HuY6bPjyaAa0JzguM,21
38
- MLVisualizationTools-0.7.0.dist-info/RECORD,,
36
+ MLVisualizationTools-0.7.2.dist-info/LICENSE,sha256=_51uDCYkBuFe8igxf5GL1MeYy_U9yux8fwvXLRHDOdM,1050
37
+ MLVisualizationTools-0.7.2.dist-info/METADATA,sha256=TFkETB1Dk2ymInHzI_jm1NThcB9EBPy_yFqG1WRt_5A,6543
38
+ MLVisualizationTools-0.7.2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
39
+ MLVisualizationTools-0.7.2.dist-info/top_level.txt,sha256=lOdCZd0Sb0J6Cf_--kCquNmij5HuY6bPjyaAa0JzguM,21
40
+ MLVisualizationTools-0.7.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.41.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5