-
Notifications
You must be signed in to change notification settings - Fork 68
Vb/classification missing confidence al 5239 #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vbrodsky
merged 3 commits into
develop
from
VB/classification-missing-confidence_AL-5239
Mar 21, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,12 @@ | ||
| from labelbox.data.annotation_types.classification.classification import Text | ||
|
|
||
|
|
||
| def test_text(): | ||
| text_entity = Text(answer="good job") | ||
| assert text_entity.answer == "good job" | ||
|
|
||
|
|
||
| def test_text_confidence(): | ||
| text_entity = Text(answer="good job", confidence=0.5) | ||
| assert text_entity.answer == "good job" | ||
| assert text_entity.confidence == 0.5 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,43 @@ | ||
| import json | ||
| from labelbox.data.annotation_types.annotation import ClassificationAnnotation | ||
| from labelbox.data.annotation_types.classification.classification import Checklist, ClassificationAnswer, Radio | ||
| from labelbox.data.annotation_types.data.text import TextData | ||
| from labelbox.data.annotation_types.label import Label | ||
|
|
||
| from labelbox.data.serialization.ndjson.converter import NDJsonConverter | ||
|
|
||
|
|
||
| def test_serialization(): | ||
| label = Label(uid="ckj7z2q0b0000jx6x0q2q7q0d", | ||
| data=TextData( | ||
| uid="bkj7z2q0b0000jx6x0q2q7q0d", | ||
| text="This is a test", | ||
| ), | ||
| annotations=[ | ||
| ClassificationAnnotation( | ||
| name="checkbox_question_geo", | ||
| confidence=0.5, | ||
| value=Checklist(answer=[ | ||
| ClassificationAnswer(name="first_answer"), | ||
| ClassificationAnswer(name="second_answer") | ||
| ])) | ||
| ]) | ||
|
|
||
| serialized = NDJsonConverter.serialize([label]) | ||
|
|
||
| res = next(serialized) | ||
| assert res['confidence'] == 0.5 | ||
| assert res['name'] == "checkbox_question_geo" | ||
| assert res['answer'][0]['name'] == "first_answer" | ||
| assert res['answer'][1]['name'] == "second_answer" | ||
| assert res['dataRow']['id'] == "bkj7z2q0b0000jx6x0q2q7q0d" | ||
|
|
||
| deserialized = NDJsonConverter.deserialize([res]) | ||
| res = next(deserialized) | ||
| annotation = res.annotations[0] | ||
| assert annotation.confidence == 0.5 | ||
|
|
||
| annotation_value = annotation.value | ||
| assert type(annotation_value) is Checklist | ||
| assert annotation_value.answer[0].name == "first_answer" | ||
| assert annotation_value.answer[1].name == "second_answer" |
This file contains hidden or 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,39 @@ | ||
| import json | ||
| from labelbox.data.annotation_types.annotation import ClassificationAnnotation | ||
| from labelbox.data.annotation_types.classification.classification import ClassificationAnswer, Radio | ||
| from labelbox.data.annotation_types.data.text import TextData | ||
| from labelbox.data.annotation_types.label import Label | ||
|
|
||
| from labelbox.data.serialization.ndjson.converter import NDJsonConverter | ||
|
|
||
|
|
||
| def test_serialization(): | ||
| label = Label(uid="ckj7z2q0b0000jx6x0q2q7q0d", | ||
| data=TextData( | ||
| uid="bkj7z2q0b0000jx6x0q2q7q0d", | ||
| text="This is a test", | ||
| ), | ||
| annotations=[ | ||
| ClassificationAnnotation( | ||
| name="radio_question_geo", | ||
| confidence=0.5, | ||
| value=Radio(answer=ClassificationAnswer( | ||
| confidence=0.6, name="first_radio_answer"))) | ||
| ]) | ||
|
|
||
| serialized = NDJsonConverter.serialize([label]) | ||
| res = next(serialized) | ||
| assert res['confidence'] == 0.5 | ||
| assert res['name'] == "radio_question_geo" | ||
| assert res['answer']['name'] == "first_radio_answer" | ||
| assert res['answer']['confidence'] == 0.6 | ||
| assert res['dataRow']['id'] == "bkj7z2q0b0000jx6x0q2q7q0d" | ||
|
|
||
| deserialized = NDJsonConverter.deserialize([res]) | ||
| res = next(deserialized) | ||
| annotation = res.annotations[0] | ||
| assert annotation.confidence == 0.5 | ||
|
|
||
| annotation_value = annotation.value | ||
| assert type(annotation_value) is Radio | ||
| assert annotation_value.answer.name == "first_radio_answer" |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,20 +1,37 @@ | ||
| import json | ||
| from labelbox.data.annotation_types.annotation import ClassificationAnnotation | ||
| from labelbox.data.annotation_types.classification.classification import ClassificationAnswer, Radio, Text | ||
| from labelbox.data.annotation_types.data.text import TextData | ||
| from labelbox.data.annotation_types.label import Label | ||
|
|
||
| from labelbox.data.serialization.ndjson.converter import NDJsonConverter | ||
|
|
||
|
|
||
| def test_text(): | ||
| with open('tests/data/assets/ndjson/text_import.json', 'r') as file: | ||
| data = json.load(file) | ||
| res = list(NDJsonConverter.deserialize(data)) | ||
| res = list(NDJsonConverter.serialize(res)) | ||
| assert res == data | ||
| def test_serialization(): | ||
| label = Label(uid="ckj7z2q0b0000jx6x0q2q7q0d", | ||
| data=TextData( | ||
| uid="bkj7z2q0b0000jx6x0q2q7q0d", | ||
| text="This is a test", | ||
| ), | ||
| annotations=[ | ||
| ClassificationAnnotation( | ||
| name="radio_question_geo", | ||
| confidence=0.5, | ||
| value=Text(answer="first_radio_answer")) | ||
| ]) | ||
|
|
||
| serialized = NDJsonConverter.serialize([label]) | ||
| res = next(serialized) | ||
| assert res['confidence'] == 0.5 | ||
| assert res['name'] == "radio_question_geo" | ||
| assert res['answer'] == "first_radio_answer" | ||
| assert res['dataRow']['id'] == "bkj7z2q0b0000jx6x0q2q7q0d" | ||
|
|
||
| def test_text_name_only(): | ||
| with open('tests/data/assets/ndjson/text_import_name_only.json', | ||
| 'r') as file: | ||
| data = json.load(file) | ||
| res = list(NDJsonConverter.deserialize(data)) | ||
| res = list(NDJsonConverter.serialize(res)) | ||
| assert res == data | ||
| deserialized = NDJsonConverter.deserialize([res]) | ||
| res = next(deserialized) | ||
| annotation = res.annotations[0] | ||
| assert annotation.confidence == 0.5 | ||
|
|
||
| annotation_value = annotation.value | ||
| assert type(annotation_value) is Text | ||
| assert annotation_value.answer == "first_radio_answer" | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.