Skip to content

Commit

Permalink
Merge pull request #73 from open-contracting/red-flags
Browse files Browse the repository at this point in the history
Red flags
  • Loading branch information
yolile authored Nov 7, 2024
2 parents ceb143c + 4d1374c commit ac9a0fe
Show file tree
Hide file tree
Showing 15 changed files with 11,604 additions and 8 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Notebook | Open in Colab | Description
[Structure and format feedback template](https://github.com/open-contracting/notebooks-ocds/blob/main/template_structure_and_format_feedback.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_structure_and_format_feedback.ipynb) | Provide feedback on structure and format errors reported by [lib-cove-ocds](https://github.com/open-contracting/lib-cove-ocds).
[Data quality feedback template](https://github.com/open-contracting/notebooks-ocds/blob/main/template_data_quality_feedback.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_data_quality_feedback.ipynb) | Provide detailed feedback on structure, format, conformance and quality issues.
[Usability checks template](https://github.com/open-contracting/notebooks-ocds/blob/main/template_usability_checks.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_usability_checks.ipynb) | Provide feedback on data usability for OCDS datasets.
[Red flags checks template](https://github.com/open-contracting/notebooks-ocds/blob/main/template_red_flags_checks.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_red_flags_checks.ipynb) | Provide feedback on red flags for OCDS datasets.

### Other data sources

Expand All @@ -40,6 +41,9 @@ Notebook | Open in Colab | Description
[Relevant checks using a field list](https://github.com/open-contracting/notebooks-ocds/blob/main/template_relevant_checks_fieldlist.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_relevant_checks_fieldlist.ipynb) | Provide feedback on data relevance for prospective publishers, using a field list, like from a field-level mapping.
[Relevant checks using the Data Registry](https://github.com/open-contracting/notebooks-ocds/blob/main/template_relevant_checks_registry.ipynb) | [![Open Iinn Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_relevant_checks_registry.ipynb) | Provide feedback on data relevance using data from the [Data Registry](https://data.open-contracting.org/).
[Relevant checks for all the Data Registry publications](https://github.com/open-contracting/notebooks-ocds/blob/main/template_relevant_checks_registry_all.ipynb) | [![Open Iinn Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_relevant_checks_registry_all.ipynb) | Provide feedback on data relevance downloading all the publications from the [Data Registry](https://data.open-contracting.org/).
[Red flags checks using the Data Registry](https://github.com/open-contracting/notebooks-ocds/blob/main/template_red_flags_checks_registry.ipynb) | [![Open Iinn Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_red_flags_checks_registry.ipynb) | Provide feedback on coverage for red flags using data from the [Data Registry](https://data.open-contracting.org/).
[Red flags checks using a field list](https://github.com/open-contracting/notebooks-ocds/blob/main/template_red_flags_checks_fieldlist.ipynb) | [![Open Iinn Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/template_red_flags_checks_fieldlist.ipynb) | Provide feedback on red flags for prospective OCDS publishers, using a field list, like from a field-level mapping.


## Contributing

Expand Down Expand Up @@ -69,6 +73,7 @@ Component name | Open in Colab | Tasks
[Usability checks using a field list without coverage](https://github.com/open-contracting/notebooks-ocds/blob/main/component_check_usability_external.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/component_check_usability_external.ipynb) |
[Relevant checks using a field list](https://github.com/open-contracting/notebooks-ocds/blob/main/component_check_relevant.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/component_check_relevant.ipynb) | Given a field list, check if the list pass the "relevant" criteria.
[Relevant checks against all the publications from the Data Registry](https://github.com/open-contracting/notebooks-ocds/blob/main/component_check_relevant_all_registry.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/component_check_relevant_all_registry.ipynb) | Downloads all the publications from the registry and performs the "relevant" checks against the active ones.
[Red flags checks using a field list without coverage](https://github.com/open-contracting/notebooks-ocds/blob/main/component_check_red_flags_external.ipynb) | [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/open-contracting/notebooks-ocds/blob/main/component_check_red_flags_external.ipynb) |

Use the buttons above to open the components from the `main` branch for editing in Google Colaboratory (Colab).

Expand Down
172 changes: 172 additions & 0 deletions component_check_red_flags_external.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"toc_visible": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"source": [
"## Usability analysis"
],
"metadata": {
"id": "s75VrpzLRNkx"
}
},
{
"cell_type": "markdown",
"source": [
"Generate a list of the fields published:"
],
"metadata": {
"id": "HTkFw9jajocD"
}
},
{
"cell_type": "code",
"source": [
"fields_list = fields_table.iloc[:, 0].tolist()"
],
"metadata": {
"id": "MgZ3TsCOjozN"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"indicators_dic = get_red_flags_dictionary(fields_list)\n",
"result = redflags_checks(fields_list, indicators_dic)"
],
"metadata": {
"id": "xrxFlHz9Hk48"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"### Export results"
],
"metadata": {
"id": "Fvej9yl_H5oE"
}
},
{
"cell_type": "markdown",
"source": [
"#### Load use case indicators spreadsheet"
],
"metadata": {
"id": "EBmaz2VRITHf"
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"result_final = check_red_flags_indicators(result)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"#### Table of results"
],
"metadata": {
"id": "sbcQgxItIodv"
}
},
{
"cell_type": "code",
"source": [
"result_final"
],
"metadata": {
"id": "hMJH_IpAIm9V"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"#### Results summary"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"table = result_final.groupby(\"calculation\").agg(total_red_flags=(\"R_id\", \"count\")).reset_index()\n",
"table[\"%\"] = round(table[\"total_red_flags\"] / table[\"total_red_flags\"].sum() * 100, 1)\n",
"table"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"#### Most common fields to indicators"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"common_fields = most_common_fields_to_calculate_indicators(indicators_dic, fields_table)\n",
"common_fields"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"#### Save the table to a spreadsheet"
],
"metadata": {
"id": "3001zqj9IxHF"
}
},
{
"cell_type": "code",
"source": [
"set_spreadsheet_name(\"Red Flags\")\n",
"save_dataframe_to_sheet(result_final, \"red_flags_table\")\n",
"save_dataframe_to_sheet(common_fields, \"common_fields_table\")\n",
"save_dataframe_to_sheet(fields_table, \"fields_list\")"
],
"metadata": {
"id": "Qxb5b7wsI0GM"
},
"execution_count": null,
"outputs": []
}
]
}
158 changes: 158 additions & 0 deletions component_check_red_flags_kingfisher.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"toc_visible": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"source": [
"## Usability analysis"
],
"metadata": {
"id": "s75VrpzLRNkx"
}
},
{
"cell_type": "markdown",
"source": [
"Generate a list of the fields published:"
],
"metadata": {
"id": "HTkFw9jajocD"
}
},
{
"cell_type": "code",
"source": [
"fields_list = fields_table.iloc[:, 0].tolist()"
],
"metadata": {
"id": "MgZ3TsCOjozN"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"indicators_dict = get_red_flags_dictionary(fields_list)\n",
"result = redflags_checks(fields_list, indicators_dict, check_coverage=True)\n",
"result[\"coverage\"] = get_coverage(indicators_dic)"
],
"metadata": {
"id": "xrxFlHz9Hk48"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"### Export and visualize results"
],
"metadata": {
"id": "Fvej9yl_H5oE"
}
},
{
"cell_type": "markdown",
"source": [
"#### Load use case indicators spreadsheet"
],
"metadata": {
"id": "EBmaz2VRITHf"
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"result_final = check_red_flags_indicators(result)"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"#### Table of results"
],
"metadata": {
"id": "sbcQgxItIodv"
}
},
{
"cell_type": "code",
"source": [
"result_final"
],
"metadata": {
"id": "hMJH_IpAIm9V"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"#### Most common fields for indicators"
],
"metadata": {
"id": "LXRG5Di4JTC6"
}
},
{
"cell_type": "markdown",
"source": [
"This table shows the most frequent fields used to calculate indicators and if they are published. You can use this table to highlight to the publisher the key data gaps. "
],
"metadata": {
"id": "dU4jyCZyJaqx"
}
},
{
"cell_type": "code",
"source": [
"fields_count = most_common_fields_to_calculate_indicators(indicators_dict, fields_table)\n",
"fields_count"
],
"metadata": {
"id": "XZVErXpYJXxV"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"#### Save tables to spreadsheet"
],
"metadata": {
"id": "3001zqj9IxHF"
}
},
{
"cell_type": "code",
"source": [
"save_dataframe_to_sheet(result_final, \"red flags table\")\n",
"save_dataframe_to_sheet(fields_count, \"key fields\")"
],
"metadata": {
"id": "Qxb5b7wsI0GM"
},
"execution_count": null,
"outputs": []
}
]
}
Loading

0 comments on commit ac9a0fe

Please sign in to comment.