MLVisualizationTools 0.7.0__tar.gz → 0.7.2__tar.gz

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.
Files changed (49) hide show
  1. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/__init__.py +2 -1
  2. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/colorizers.py +1 -1
  3. MLVisualizationTools-0.7.2/MLVisualizationTools/examples/RemoveFeatureDemo.py +25 -0
  4. MLVisualizationTools-0.7.2/MLVisualizationTools/removefeature.py +42 -0
  5. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools.egg-info/PKG-INFO +26 -18
  6. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools.egg-info/SOURCES.txt +2 -0
  7. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/PKG-INFO +26 -18
  8. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/README.md +25 -17
  9. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/setup.cfg +1 -1
  10. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/tests/test_basic.py +5 -0
  11. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/LICENSE +0 -0
  12. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MANIFEST.in +0 -0
  13. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/backend.py +0 -0
  14. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/dashbackend.py +0 -0
  15. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/datainterface.py +0 -0
  16. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/AnimationDemo.py +0 -0
  17. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/DashDemo.py +0 -0
  18. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/DashKaggleDemo.py +0 -0
  19. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/DashNotebookDemo.py +0 -0
  20. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/DataOverlayDemo.py +0 -0
  21. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Datasets/Titanic/TitanicDemoPreprocess.py +0 -0
  22. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Datasets/Titanic/train.csv +0 -0
  23. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Datasets/Titanic/train_orig.csv +0 -0
  24. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Demo.py +0 -0
  25. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/MatplotlibDemo.py +0 -0
  26. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Models/titanicmodel/keras_metadata.pb +0 -0
  27. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Models/titanicmodel/saved_model.pb +0 -0
  28. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Models/titanicmodel/variables/variables.data-00000-of-00001 +0 -0
  29. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Models/titanicmodel/variables/variables.index +0 -0
  30. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Models/titanicmodel_v2.0/keras_metadata.pb +0 -0
  31. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Models/titanicmodel_v2.0/saved_model.pb +0 -0
  32. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Models/titanicmodel_v2.0/variables/variables.data-00000-of-00001 +0 -0
  33. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/Models/titanicmodel_v2.0/variables/variables.index +0 -0
  34. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/SklearnDemo.py +0 -0
  35. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/examples/TrainTitanicModel.py +0 -0
  36. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/express/DashModelVisualizer.py +0 -0
  37. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/express/__init__.py +0 -0
  38. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/graphinterface.py +0 -0
  39. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/modelanalytics.py +0 -0
  40. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/modelinterface.py +0 -0
  41. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/theme_assets/dark_assets/darktheme.css +0 -0
  42. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/theme_assets/light_assets/lighttheme.css +0 -0
  43. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools/types.py +0 -0
  44. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools.egg-info/dependency_links.txt +0 -0
  45. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools.egg-info/requires.txt +0 -0
  46. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/MLVisualizationTools.egg-info/top_level.txt +0 -0
  47. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/pyproject.toml +0 -0
  48. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/setup.py +0 -0
  49. {MLVisualizationTools-0.7.0 → MLVisualizationTools-0.7.2}/tests/testconf.py +0 -0
@@ -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
@@ -76,7 +76,7 @@ App.visualize(model, data)
76
76
  MLVisualizationTools connects a variety of smaller functions.
77
77
 
78
78
  Steps:
79
- 1. Keras Model and Dataframe with features
79
+ 1. Start with a ML Model and Dataframe with features
80
80
  2. Analyzer
81
81
  3. Interface / Interface Raw (if you don't have a dataframe)
82
82
  4. Colorizers (optional)
@@ -84,7 +84,7 @@ Steps:
84
84
  6. Colorize data points (Optional)
85
85
  7. Graphs
86
86
 
87
- Analyzers take a keras model and return information about the inputs
87
+ Analyzers take a ml model and return information about the inputs
88
88
  such as which ones have high variance.
89
89
 
90
90
  Interfaces take parameters and construct a multidimensional grid
@@ -137,6 +137,25 @@ notebooks
137
137
  See [MLVisualizationTools/Examples](/MLVisualizationTools/examples) for more examples.
138
138
  Use example.main() to run the examples and set parameters such as themes.
139
139
 
140
+ ## Tensorflow Compatibility
141
+
142
+ MLVisualizationTools is distributed with a pretrained tensorflow model
143
+ to make running examples quick and easy. It is not needed for main library functions.
144
+
145
+ For version 2.0 through 2.4, we load a v2.0 model.
146
+ For version 2.5+ we load a v2.5 model.
147
+
148
+ If this causes compatibility issues you can still use the main library on your models.
149
+ If you need an example model, retrain it with
150
+ [TrainTitanicModel.py](/MLVisualizationTools/examples/TrainTitanicModel.py)
151
+
152
+ ## scikit-learn Compatibility
153
+
154
+ See [SklearnDemo.py](/MLVisualizationTools/examples/SklearnDemo.py)
155
+
156
+ Sklearn can be used exactly like TF because it has the same `.predict(X) -> Y` interface.
157
+
158
+
140
159
  ## Support for more ML Libraries
141
160
 
142
161
  We support any ML library that has a `predict()` call that takes
@@ -154,20 +173,9 @@ class ModelWrapper:
154
173
  ... #Do whatever code you need here
155
174
  ```
156
175
 
157
- ## Tensorflow Compatibility
158
-
159
- MLVisualizationTools is distributed with a pretrained tensorflow model
160
- to make running examples quick and easy. It is not needed for main library functions.
161
-
162
- For version 2.0 through 2.4, we load a v2.0 model.
163
- For version 2.5+ we load a v2.5 model.
164
-
165
- If this causes compatibility issues you can still use the main library on your models.
166
- If you need an example model, retrain it with
167
- [TrainTitanicModel.py](/MLVisualizationTools/examples/TrainTitanicModel.py)
168
-
169
- ## scikit-learn Compatibility
176
+ ## Remove Feature Testing
170
177
 
171
- See [SklearnDemo.py](/MLVisualizationTools/examples/SklearnDemo.py)
178
+ See [RemoveFeatureDemo.py](/MLVisualizationTools/examples/RemoveFeatureDemo.py)
172
179
 
173
- Sklearn can be used exactly like TF because it has the same `.predict(X, Y)` interface.
180
+ Tests if features can be removed from dataset without significantly affecting accuracy.
181
+ Replaces each dataset column with mean and compares to baseline accuracy.
@@ -12,6 +12,7 @@ MLVisualizationTools/datainterface.py
12
12
  MLVisualizationTools/graphinterface.py
13
13
  MLVisualizationTools/modelanalytics.py
14
14
  MLVisualizationTools/modelinterface.py
15
+ MLVisualizationTools/removefeature.py
15
16
  MLVisualizationTools/types.py
16
17
  MLVisualizationTools.egg-info/PKG-INFO
17
18
  MLVisualizationTools.egg-info/SOURCES.txt
@@ -25,6 +26,7 @@ MLVisualizationTools/examples/DashNotebookDemo.py
25
26
  MLVisualizationTools/examples/DataOverlayDemo.py
26
27
  MLVisualizationTools/examples/Demo.py
27
28
  MLVisualizationTools/examples/MatplotlibDemo.py
29
+ MLVisualizationTools/examples/RemoveFeatureDemo.py
28
30
  MLVisualizationTools/examples/SklearnDemo.py
29
31
  MLVisualizationTools/examples/TrainTitanicModel.py
30
32
  MLVisualizationTools/examples/Datasets/Titanic/TitanicDemoPreprocess.py
@@ -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
@@ -76,7 +76,7 @@ App.visualize(model, data)
76
76
  MLVisualizationTools connects a variety of smaller functions.
77
77
 
78
78
  Steps:
79
- 1. Keras Model and Dataframe with features
79
+ 1. Start with a ML Model and Dataframe with features
80
80
  2. Analyzer
81
81
  3. Interface / Interface Raw (if you don't have a dataframe)
82
82
  4. Colorizers (optional)
@@ -84,7 +84,7 @@ Steps:
84
84
  6. Colorize data points (Optional)
85
85
  7. Graphs
86
86
 
87
- Analyzers take a keras model and return information about the inputs
87
+ Analyzers take a ml model and return information about the inputs
88
88
  such as which ones have high variance.
89
89
 
90
90
  Interfaces take parameters and construct a multidimensional grid
@@ -137,6 +137,25 @@ notebooks
137
137
  See [MLVisualizationTools/Examples](/MLVisualizationTools/examples) for more examples.
138
138
  Use example.main() to run the examples and set parameters such as themes.
139
139
 
140
+ ## Tensorflow Compatibility
141
+
142
+ MLVisualizationTools is distributed with a pretrained tensorflow model
143
+ to make running examples quick and easy. It is not needed for main library functions.
144
+
145
+ For version 2.0 through 2.4, we load a v2.0 model.
146
+ For version 2.5+ we load a v2.5 model.
147
+
148
+ If this causes compatibility issues you can still use the main library on your models.
149
+ If you need an example model, retrain it with
150
+ [TrainTitanicModel.py](/MLVisualizationTools/examples/TrainTitanicModel.py)
151
+
152
+ ## scikit-learn Compatibility
153
+
154
+ See [SklearnDemo.py](/MLVisualizationTools/examples/SklearnDemo.py)
155
+
156
+ Sklearn can be used exactly like TF because it has the same `.predict(X) -> Y` interface.
157
+
158
+
140
159
  ## Support for more ML Libraries
141
160
 
142
161
  We support any ML library that has a `predict()` call that takes
@@ -154,20 +173,9 @@ class ModelWrapper:
154
173
  ... #Do whatever code you need here
155
174
  ```
156
175
 
157
- ## Tensorflow Compatibility
158
-
159
- MLVisualizationTools is distributed with a pretrained tensorflow model
160
- to make running examples quick and easy. It is not needed for main library functions.
161
-
162
- For version 2.0 through 2.4, we load a v2.0 model.
163
- For version 2.5+ we load a v2.5 model.
164
-
165
- If this causes compatibility issues you can still use the main library on your models.
166
- If you need an example model, retrain it with
167
- [TrainTitanicModel.py](/MLVisualizationTools/examples/TrainTitanicModel.py)
168
-
169
- ## scikit-learn Compatibility
176
+ ## Remove Feature Testing
170
177
 
171
- See [SklearnDemo.py](/MLVisualizationTools/examples/SklearnDemo.py)
178
+ See [RemoveFeatureDemo.py](/MLVisualizationTools/examples/RemoveFeatureDemo.py)
172
179
 
173
- Sklearn can be used exactly like TF because it has the same `.predict(X, Y)` interface.
180
+ Tests if features can be removed from dataset without significantly affecting accuracy.
181
+ Replaces each dataset column with mean and compares to baseline accuracy.
@@ -53,7 +53,7 @@ App.visualize(model, data)
53
53
  MLVisualizationTools connects a variety of smaller functions.
54
54
 
55
55
  Steps:
56
- 1. Keras Model and Dataframe with features
56
+ 1. Start with a ML Model and Dataframe with features
57
57
  2. Analyzer
58
58
  3. Interface / Interface Raw (if you don't have a dataframe)
59
59
  4. Colorizers (optional)
@@ -61,7 +61,7 @@ Steps:
61
61
  6. Colorize data points (Optional)
62
62
  7. Graphs
63
63
 
64
- Analyzers take a keras model and return information about the inputs
64
+ Analyzers take a ml model and return information about the inputs
65
65
  such as which ones have high variance.
66
66
 
67
67
  Interfaces take parameters and construct a multidimensional grid
@@ -114,6 +114,25 @@ notebooks
114
114
  See [MLVisualizationTools/Examples](/MLVisualizationTools/examples) for more examples.
115
115
  Use example.main() to run the examples and set parameters such as themes.
116
116
 
117
+ ## Tensorflow Compatibility
118
+
119
+ MLVisualizationTools is distributed with a pretrained tensorflow model
120
+ to make running examples quick and easy. It is not needed for main library functions.
121
+
122
+ For version 2.0 through 2.4, we load a v2.0 model.
123
+ For version 2.5+ we load a v2.5 model.
124
+
125
+ If this causes compatibility issues you can still use the main library on your models.
126
+ If you need an example model, retrain it with
127
+ [TrainTitanicModel.py](/MLVisualizationTools/examples/TrainTitanicModel.py)
128
+
129
+ ## scikit-learn Compatibility
130
+
131
+ See [SklearnDemo.py](/MLVisualizationTools/examples/SklearnDemo.py)
132
+
133
+ Sklearn can be used exactly like TF because it has the same `.predict(X) -> Y` interface.
134
+
135
+
117
136
  ## Support for more ML Libraries
118
137
 
119
138
  We support any ML library that has a `predict()` call that takes
@@ -131,20 +150,9 @@ class ModelWrapper:
131
150
  ... #Do whatever code you need here
132
151
  ```
133
152
 
134
- ## Tensorflow Compatibility
135
-
136
- MLVisualizationTools is distributed with a pretrained tensorflow model
137
- to make running examples quick and easy. It is not needed for main library functions.
138
-
139
- For version 2.0 through 2.4, we load a v2.0 model.
140
- For version 2.5+ we load a v2.5 model.
141
-
142
- If this causes compatibility issues you can still use the main library on your models.
143
- If you need an example model, retrain it with
144
- [TrainTitanicModel.py](/MLVisualizationTools/examples/TrainTitanicModel.py)
145
-
146
- ## scikit-learn Compatibility
153
+ ## Remove Feature Testing
147
154
 
148
- See [SklearnDemo.py](/MLVisualizationTools/examples/SklearnDemo.py)
155
+ See [RemoveFeatureDemo.py](/MLVisualizationTools/examples/RemoveFeatureDemo.py)
149
156
 
150
- Sklearn can be used exactly like TF because it has the same `.predict(X, Y)` interface.
157
+ Tests if features can be removed from dataset without significantly affecting accuracy.
158
+ Replaces each dataset column with mean and compares to baseline accuracy.
@@ -6,7 +6,7 @@ license = MIT
6
6
  license_file = LICENSE
7
7
  url = https://github.com/RobertJN64/MLVisualizationTools
8
8
  author_email = robertjnies@gmail.com
9
- version = 0.7.0
9
+ version = 0.7.2
10
10
  long_description = file: README.md
11
11
  long_description_content_type = text/markdown
12
12
  classifiers =
@@ -212,3 +212,8 @@ def test_unusual_dataoverlay():
212
212
  project.Graphs.plotlyGraph(anim)
213
213
  project.Graphs.plotlyGraph(panim)
214
214
  project.Graphs.matplotlibGraph(grid)
215
+
216
+ def test_rm_feature():
217
+ from MLVisualizationTools.examples import RemoveFeatureDemo
218
+ RemoveFeatureDemo.main() #verbose true
219
+ RemoveFeatureDemo.main(False) #verbose false