-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TFDV, TFMA, and Table visualization support for Python based visu…
…alizations (#1898) * Added table and tfdv visualization Also fixed issue surrounding ApiVisualizationType enum * Fixed table visualization * Removed byte limit * Fixed issue where headers would not properly be applied * Fixed issue where table would not be intractable * Updated table visualizaiton to reflect changes made to dependency injection * Fixed bug where checking if headers is provided to table visualizations could crash visualization * Added TFMA visualization * Updated new visualizations to match syntax of #1878 * Updated test snapshots to account for TFMA visualization * Small if statement synax changes * Add flake8 noqa comments to table.py and tfma.py
- Loading branch information
1 parent
db6c9b4
commit 3c8952e
Showing
11 changed files
with
322 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright 2019 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# gcsfs is required for pandas GCS integration. | ||
import gcsfs | ||
from itables import show | ||
# itables is requires as importing it changes the way pandas DataFrames are | ||
# rendered. | ||
import itables.interactive | ||
import itables.options as opts | ||
import pandas as pd | ||
from tensorflow.python.lib.io import file_io | ||
|
||
# flake8: noqa TODO | ||
|
||
# Remove maxByte limit to prevent issues where entire table cannot be rendered | ||
# due to size of data. | ||
opts.maxBytes = 0 | ||
|
||
dfs = [] | ||
files = file_io.get_matching_files(source) | ||
|
||
# Read data from file and write it to a DataFrame object. | ||
if variables.get("headers", False) == False: | ||
# If no headers are provided, use the first row as headers | ||
for f in files: | ||
dfs.append(pd.read_csv(f)) | ||
else: | ||
# If headers are provided, do not set headers for DataFrames | ||
for f in files: | ||
dfs.append(pd.read_csv(f, header=None)) | ||
|
||
# Display DataFrame as output. | ||
df = pd.concat(dfs) | ||
if variables.get("headers", False) != False: | ||
df.columns = variables.get("headers") | ||
show(df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright 2019 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import tensorflow_model_analysis as tfma | ||
|
||
# flake8: noqa TODO | ||
|
||
if variables.get("slicing_column", False) == False { | ||
tfma.view.render_slicing_metrics(source) | ||
} else { | ||
tfma.view.render_slicing_metrics(source, slicing_column=variables.get("slicing_column")) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.