Code.gov Data Quality Scoring

December 31, 2022 ยท View on GitHub

As part of our efforts to make Code.gov as useful as possible to our users, we have implemented rules to score the quality of the data being indexed into Code.gov. This score is not a judgement or critique of the data itself, but an effort on our part to quantify the data we have determined our users look for and need while using our site and API.

Score Determination

We determine the quality score of a repository by using a series of rules and passing the repository through a rules engine. We also assign a point value to each field that symbolizes the value that field has for Code.gov.

The rules can vary from field to field. As an example, we evaluate the existence of data in all fields before we add their weight to the overall score, but in the case of the description field we also evaluate that the content of the field is not the same as the name of the project and we make a "naive" evaluation on the amount of content that the field has (word count). Other fields are evaluated depending on the data that is expected and desired in them.

Field Points

We give point values between 0 and 10. These values are the maximum score that data in the field can obtain. There are fields where data is evaluated and may be awarded less than the values in the following table. Also, fields like tags may be awarded partial value based on number of items

Field NameMax Field PointsRequiredNotes
name10yes
version1yes
organization5
description10yes0 points if descriptions and name are same, 0 points if description is less then 3 words, 3 points if description is less then 10 words, 5 points if description is less then 20 words, 8 points if description is less then 30 words, 10 (full) points if description is 30 or more words
permissions.licenses.URL1Licenses is an Array of objects and it should have at least 1 element
permissions.licenses.name7Licenses is an Array of objects and it should have at least 1 element
permissions.usageType10yes1 point if exempt*, 5 points if governmentWideReuse, 10 (full) points if openSource'
permissions.exemptionText55 (full) points if usageType is openSource/governmentWideReuse OR exemptionText is present, 0 otherwise
tags10yesTags is an Array objects, 4 points if 1 tag element, 6 points if 2 tag elements, 10 (full) points if 3 or more tag elements
contact.email10yes
contact.name5
contact.URL5
contact.phone5
status5
vcs5
repositoryURL10yes10 (full) points if valid URL (starts with https:// or http://)
homepageURL7must exists and be a valid URL to get full points
downloadURL3must exists and be a valid URL to get full points
disclaimerURL3must exists and be a valid URL to get full points
disclaimerText3
languages10Languages is an Array of strings, must have at least 1 element to get full points
laborHours10yesFull points if a positive numeric value
relatedCode.name1
relatedCode.URL1must exists and be a valid URL to get full points
relatedCode.isGovernmentRepo1
reusedCode.name1
reusedCode.URL1must exists and be a valid URL to get full points
partners.name1
partners.email1
date.created5
date.lastModified5
date.metadataLastUpdated2

Field Rules

We are using the simple-rules-engine package to evaluate the rules we've created for each field. Our current rules can be seen here.

Score Normalization

Score normalization is performed where the final score is between 0 and 10. To arrive at this value, all point values of each field in the above table are tallied and divided by maximum possible point and then multiplied by 10.

Score Display

The code.gov front end uses a corner tag to display the data quality score. This is implemented by the quality-tag component. The tag type/color is determined by the score value passed to the component using the following ranges:

  • low/red: a score below 4
  • medium/orange: a score greater than or equal to 4 and less than 6
  • high/green: a score higher than or equal to 6

*Note: because all code.gov projects should have the required fields filled, the majority of projects will have the medium/orange data quality corner tag.

Check out our Metadata Examples document for additional information on metadata to include in order to raise your data quality score.

For more info on the code.gov corner tags see the style guide.

See quality_tag.js to view the code for this corner tag component logic.