Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 236960625
  • Loading branch information
tf-metadata-team authored and mzinkevi committed Mar 6, 2019
1 parent 4293915 commit 0ae20fd
Show file tree
Hide file tree
Showing 10 changed files with 516 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The metadata serialization formats include:

* A schema describing tabular data (e.g., tf.Examples).
* A collection of summary statistics over such datasets.
* A problem statement quantifying the objectives of a model.

The metadata may be produced by hand or automatically during input data
analysis, and may be consumed for data validation, exploration, and
Expand Down
13 changes: 12 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# Version 0.13.0

## Major Features and Improvements

* Added ProblemStatement.

## Bug Fixes and Other Changes

## Breaking changes

## Deprecations

# Version 0.12.0

## Major Features and Improvements

* Added ProblemStatement
* Add support for declaring sparse features.
* Add support for schema diff regions.

Expand Down
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
from setuptools import find_packages
from setuptools import setup

with open('tensorflow_metadata/version.py') as fp:
globals_dict = {}
exec (fp.read(), globals_dict) # pylint: disable=exec-used

# tf.Metadata version.
__version__ = '0.12.0'
__version__ = globals_dict['__version__']


# Note: In order for the README to be rendered correctly, make sure to have the
# following minimum required versions of the respective packages when building
Expand Down Expand Up @@ -58,8 +63,7 @@
install_requires=[
'googleapis-common-protos',

# TF now requires protobuf>=3.6.1.
'protobuf>=3.6.1,<4',
'protobuf>=3.7,<4',
],
python_requires='>=2.7,<4',
packages=find_packages(),
Expand All @@ -68,5 +72,5 @@
long_description=_LONG_DESCRIPTION,
long_description_content_type='text/markdown',
keywords='tensorflow metadata tfx',
download_url='https://pypi.org/project/tensorflow-metadata',
download_url='https://github.com/tensorflow/metadata/tags',
requires=[])
9 changes: 9 additions & 0 deletions tensorflow_metadata/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
licenses(["notice"]) # Apache 2.0

sh_binary(
name = "build_pip_package",
srcs = ["build_pip_package.sh"],
data = [
"//tensorflow_metadata/proto/v0:metadata_v0_proto_py_pb2",
],
)
54 changes: 54 additions & 0 deletions tensorflow_metadata/build_pip_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash
# Copyright 2018 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.

# Convenience binary to build TFMD from source.

# Put wrapped c++ files in place

# Usage: build_pip_package.sh [--python_bin_path PYTHON_BIN_PATH]

if [[ -z "$1" ]]; then
PYTHON_BIN_PATH=python
else
if [[ "$1" == --python_bin_path ]]; then
shift
PYTHON_BIN_PATH=$1
else
printf "Unrecognized argument $1"
exit 1
fi
fi

set -u -x

cp -f tensorflow_metadata/proto/v0/schema_pb2.py \
${BUILD_WORKSPACE_DIRECTORY}/tensorflow_metadata/proto/v0

cp -f tensorflow_metadata/proto/v0/path_pb2.py \
${BUILD_WORKSPACE_DIRECTORY}/tensorflow_metadata/proto/v0

cp -f tensorflow_metadata/proto/v0/anomalies_pb2.py \
${BUILD_WORKSPACE_DIRECTORY}/tensorflow_metadata/proto/v0

cp -f tensorflow_metadata/proto/v0/statistics_pb2.py \
${BUILD_WORKSPACE_DIRECTORY}/tensorflow_metadata/proto/v0

# Create the wheel
cd ${BUILD_WORKSPACE_DIRECTORY}

${PYTHON_BIN_PATH} setup.py bdist_wheel

# Cleanup
cd -
4 changes: 4 additions & 0 deletions tensorflow_metadata/proto/v0/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ cc_proto_library(
name = "metadata_v0_proto_cc_pb2",
srcs = [
"anomalies.proto",
"metric.proto",
"path.proto",
"problem_statement.proto",
"schema.proto",
"statistics.proto",
],
Expand All @@ -37,7 +39,9 @@ py_proto_library(
name = "metadata_v0_proto_py_pb2",
srcs = [
"anomalies.proto",
"metric.proto",
"path.proto",
"problem_statement.proto",
"schema.proto",
"statistics.proto",
],
Expand Down
184 changes: 184 additions & 0 deletions tensorflow_metadata/proto/v0/metric.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// Copyright 2017 The TensorFlow Authors. All Rights Reserved.
//
// 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.
// =============================================================================

syntax = "proto3";

option cc_enable_arenas = true;

package tensorflow.metadata.v0;

option java_package = "org.tensorflow.metadata.v0";
option java_multiple_files = true;


// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/binary_accuracy
message BinaryAccuracy {
}


// categorical_accuracy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/categorical_accuracy
message CategoricalAccuracy {
}

// categorical_crossentropy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/categorical_crossentropy
message CategoricalCrossEntropy {
}

// cosine(...)
// cosine_proximity(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/cosine_proximity
message Cosine {
}


// Linear Hinge Loss
// hinge(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/hinge
message Hinge {
}

// kld(...)
// kullback_leibler_divergence(...)
// KLD(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/kullback_leibler_divergence
message KullbackLeiblerDivergence {
}

// MAE(...)
// mae(...)
// mean_absolute_error(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/mean_absolute_error
message MeanAbsoluteError {
}

// MAPE(...)
// mape(...)
// mean_absolute_percentage_error(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/mean_absolute_percentage_error
message MeanAbsolutePercentageError {
}

// MSE(...)
// mse(...)
// mean_squared_error(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/mean_squared_error
message MeanSquaredError {
}

// msle(...)
// MSLE(...)
// mean_squared_logarithmic_error(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/mean_squared_logarithmic_error
message MeanSquaredLogarithmicError {
}

// poisson(...)
message Poisson {
}

// squared_hinge(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/squared_hinge
message SquaredHinge {
}

// top_k_categorical_accuracy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/top_k_categorical_accuracy
message TopKCategoricalAccuracy {

}

// sparse_top_k_categorical_accuracy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/sparse_top_k_categorical_accuracy
message SparseTopKCategoricalAccuracy {
}

// Binary cross entropy as a metric is equal to the negative log likelihood
// (see logistic regression).
// In addition, when used to solve a binary classification task, binary cross
// entropy implies that the binary label will maximize binary accuracy.
// binary_crossentropy(...)
// https://www.tensorflow.org/api_docs/python/tf/keras/metrics/binary_crossentropy
message BinaryCrossEntropy {
}

// AKA the negative log likelihood or log loss.
// Given a label y\in {0,1} and a predicted probability p in [0,1]:
// -yln(p)-(1-y)ln(1-p)
// TODO(martinz): if this is interpreted the same as binary_cross_entropy,
// we may need to revisit the semantics.
message LogisticRegression {
}


message AUC {
}

message PrecisionAtK {

}

message MeanReciprocalRank {
}

message BlockUtility {
repeated double weight = 1;
}

// A custom metric.
message CustomMetric {
// The name of a metric computed by the model.
string name = 1;
}

// Objective functions are performance metrics that are differentiable, and
// therefore can be directly optimized.
// TODO(martinz): take metrics that are appropriate and make them objectives.
message ObjectiveFunction {
oneof objective {
BinaryCrossEntropy binary_cross_entropy = 1;
LogisticRegression logistic_regression = 2;
MeanSquaredError squared_error = 3;
CustomMetric custom_metric = 4;
}
}

// Performance metrics measure the quality of a model. They need not be
// differentiable.
message PerformanceMetric {
oneof performance_metric {
AUC auc = 1;
BinaryAccuracy binary_accuracy = 2;
BinaryCrossEntropy binary_cross_entropy = 3;
BlockUtility block_utility = 4;
CategoricalAccuracy categorical_accuracy = 5;
CategoricalCrossEntropy categorical_cross_entropy = 6;
Cosine cosine = 7;
Hinge hinge = 8;
KullbackLeiblerDivergence kullback_leibler_divergence = 9;
LogisticRegression logistic_regression = 10;
MeanAbsoluteError mean_absolute_error = 11;
MeanAbsolutePercentageError mean_absolute_percentage_error = 12;
MeanSquaredError squared_error = 13;
MeanSquaredLogarithmicError mean_squared_logarithmic_error = 14;
MeanReciprocalRank mean_reciprocal_rank = 15;
Poisson poisson = 16;
PrecisionAtK precision_at_k = 17;
SquaredHinge squared_hinge = 18;
SparseTopKCategoricalAccuracy sparse_top_k_categorical_accuracy = 19;
TopKCategoricalAccuracy top_k_categorical_accuracy = 20;
}
}
Loading

0 comments on commit 0ae20fd

Please sign in to comment.