Spaces:
Sleeping
Sleeping
add module default template
Browse filesFiles changed (5)
- README.md+43-5
- app.pyAdded+6
- phone_distance.pyAdded+95
- requirements.txtAdded+1
- tests.pyAdded+17
1234534567897101112131412151617181920212223242526272829303132333435363738394041424344454647484950---title: Phone Distanceemoji: 🐨colorFrom: bluecolorTo: indigodatasets:- tags:- evaluate- metricdescription: "TODO: add a description here"sdk: gradiosdk_version: 4.21.0sdk_version: 3.19.1app_file: app.pypinned: false---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference# Metric Card for Phone Distance
***Module Card Instructions:*** *Fill out the following subsections. Feel free to take a look at existing metric cards if you'd like examples.*
## Metric Description*Give a brief overview of this metric, including what task(s) it is usually used for, if any.*
## How to Use*Give general statement of how to use the metric*
*Provide simplest possible example for using the metric*
### Inputs*List all input arguments in the format below*- **input_field** *(type): Definition of input, with explanation if necessary. State any default value(s).*
### Output Values
*Explain what this metric outputs and provide an example of what the metric output looks like. Modules should return a dictionary with one or multiple key-value pairs, e.g. {"bleu" : 6.02}*
*State the range of possible values that the metric's output can take, as well as what in that range is considered good. For example: "This metric can take on any value between 0 and 100, inclusive. Higher scores are better."*
#### Values from Popular Papers*Give examples, preferrably with links to leaderboards or publications, to papers that have reported this metric, along with the values they have reported.*
### Examples*Give code examples of the metric being used. Try to include examples that clear up any potential ambiguity left from the metric description above. If possible, provide a range of examples that show both typical and atypical results, as well as examples where a variety of input parameters are passed.*
## Limitations and Bias*Note any known limitations or biases that the metric has, with links and references if possible.*
## Citation*Cite the source where this metric was introduced.*
## Further References*Add any useful further references.*123456import evaluatefrom evaluate.utils import launch_gradio_widget
module = evaluate.load("ginic/phone_distance")launch_gradio_widget(module)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.## 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."""TODO: Add a description here."""
import evaluateimport datasets
# TODO: Add BibTeX citation_CITATION = """\@InProceedings{huggingface:module,title = {A great new module},authors={huggingface, Inc.},year={2020}}"""
# TODO: Add description of the module here_DESCRIPTION = """\This new module is designed to solve this great ML task and is crafted with a lot of care."""
# TODO: Add description of the arguments of the module here_KWARGS_DESCRIPTION = """Calculates how good are predictions given some references, using certain scoresArgs: predictions: list of predictions to score. Each predictions should be a string with tokens separated by spaces. references: list of reference for each prediction. Each reference should be a string with tokens separated by spaces.Returns: accuracy: description of the first score, another_score: description of the second score,Examples: Examples should be written in doctest format, and should illustrate how to use the function.
>>> my_new_module = evaluate.load("my_new_module") >>> results = my_new_module.compute(references=[0, 1], predictions=[0, 1]) >>> print(results) {'accuracy': 1.0}"""
# TODO: Define external resources urls if neededBAD_WORDS_URL = "http://url/to/external/resource/bad_words.txt"
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)class PhoneDistance(evaluate.Metric): """TODO: Short description of my evaluation module."""
def _info(self): # TODO: Specifies the evaluate.EvaluationModuleInfo object return evaluate.MetricInfo( # This is the description that will appear on the modules page. module_type="metric", description=_DESCRIPTION, citation=_CITATION, inputs_description=_KWARGS_DESCRIPTION, # This defines the format of each prediction and reference features=datasets.Features({ 'predictions': datasets.Value('int64'), 'references': datasets.Value('int64'), }), # Homepage of the module for documentation homepage="http://module.homepage", # Additional links to the codebase or references codebase_urls=["http://github.com/path/to/codebase/of/new_module"], reference_urls=["http://path.to.reference.url/new_module"] )
def _download_and_prepare(self, dl_manager): """Optional: download external resources useful to compute the scores""" # TODO: Download external resources if needed pass
def _compute(self, predictions, references): """Returns the scores""" # TODO: Compute the different scores of the module accuracy = sum(i == j for i, j in zip(predictions, references)) / len(predictions) return { "accuracy": accuracy, }1git+https://github.com/huggingface/evaluate@main1234567891011121314151617test_cases = [ { "predictions": [0, 0], "references": [1, 1], "result": {"metric_score": 0} }, { "predictions": [1, 1], "references": [1, 1], "result": {"metric_score": 1} }, { "predictions": [1, 0], "references": [1, 1], "result": {"metric_score": 0.5} }]README.md+43-5
app.pyAdded+6
phone_distance.pyAdded+95
requirements.txtAdded+1
tests.pyAdded+17