ranking

package
v1.38.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const BaseRank = 100

BaseRank is the base ranking score for sources. If a source is prefered, it should be given a score lower than BaseRank in StatsRanking. If a source is not prefered, it should be given a score higher than BaseRank in StatsRanking

Variables

View Source
var StatsRanking = map[string]map[RankKey]int{
	"USCensusPEP_Annual_Population": {{MM: s("CensusPEPSurvey"), OP: s("P1Y")}: 0},

	"CensusACS5YearSurvey": {{MM: s("CensusACS5yrSurvey")}: 1},

	"CensusACS5YearSurvey_AggCountry": {{MM: s("CensusACS5yrSurvey")}: 1},

	"CensusUSAMedianAgeIncome": {{MM: s("CensusACS5yrSurvey")}: 1},

	"USDecennialCensus_RedistrictingRelease": {{MM: s("USDecennialCensus")}: 2},

	"EurostatData": {
		{MM: s("EurostatRegionalPopulationData")}: 3,
		{MM: s("")}: 2,
	},

	"WorldDevelopmentIndicators": {{}: 4},

	"IndiaCensus_Primary": {{}: 5},

	"WikipediaStatsData": {{MM: s("Wikipedia")}: 1001},

	"HumanCuratedStats": {{MM: s("HumanCuratedStats")}: 1002},

	"WikidataPopulation": {{MM: s("WikidataPopulation")}: 1003},

	"BLS_LAUS": {{MM: s("BLSSeasonallyUnadjusted")}: 0},

	"BLS_CPS": {{MM: s("BLSSeasonallyAdjusted")}: 1},

	"NYT_COVID19": {{MM: s("NYT_COVID19_GitHub")}: 0},

	"CDC500": {{MM: s("AgeAdjustedPrevalence")}: 0},

	"UNEnergy": {{MM: s("")}: 0},

	"EIA_Electricity": {{}: 1},

	"NOAA_EPA_Observed_Historical_Weather": {{}: 0},

	"Copernicus_ECMWF_ERA5_Monthly": {{}: 1},

	"NASA_NEXDCP30": {{MM: s("NASA_Mean_CCSM4"), OP: s("P1M")}: 2},

	"NASA_NEXDCP30_AggrDiffStats": {{OP: s("P1M")}: 3},

	"NASA_NEXDCP30_StatVarSeriesAggr": {{OP: s("P1M")}: 4},

	"NASA_WetBulbComputation_Aggregation": {
		{MM: s("NASA_Mean_HadGEM2-AO")}: 0,
		{}:                              1,
	},

	"NASA_WetBulbComputation": {{MM: s("NASA_Mean_HadGEM2-AO")}: 2},

	"FBIHateCrimePublications": {{}: 0},

	"FBIHateCrime": {{}: 1},

	"USFEMA_NationalRiskIndex": {
		{Unit: s("USDollar")}:              0,
		{Unit: s("FemaNationalRiskScore")}: 1,
	},
}

StatsRanking is used to rank multiple source series for the same StatisticalVariable, where lower value means higher ranking. Outer key is Import Name, inner key is Rank Key, value is score.

Functions

func GetMetadataScore added in v1.35.0

func GetMetadataScore(m *pb.StatMetadata) int

GetMetadataScore is a GetScoreRk adapter for pb.StatMetadata

func GetScore added in v1.35.0

func GetScore(ss *model.SourceSeries) int

GetScore is a GetScoreRk adapter for model.SourceSeries TODO(shifucun): Remove `SourceSeries` and use pb.SourceSeries everywhere.

func GetScorePb added in v1.35.0

func GetScorePb(ss *pb.SourceSeries) int

GetScorePb is a GetScoreRk adapter for pb.SourceSeries

func GetScoreRk added in v1.38.0

func GetScoreRk(importName string, rk RankKey) int

GetScoreRk derives the ranking score for a source series.

The score depends on ImportName and other SVObs properties, by checking the StatsRanking dict. To get the score, ImportName is required, and a RankKey with these optional fields: - MM: MeasurementMethod - OP: ObservationPeriod

When there are exact match of the properties in StatsRanking, then use that score, otherwise can also match to wildcard options (indicated by a nil pointer).

If no entry is found, a BaseRank is assigned to the source series.

Types

type ByRank

type ByRank []*model.SourceSeries

ByRank implements sort.Interface for []*SourceSeries based on the rank score.

func (ByRank) Len

func (a ByRank) Len() int

func (ByRank) Less

func (a ByRank) Less(i, j int) bool

func (ByRank) Swap

func (a ByRank) Swap(i, j int)

type CohortByRank

type CohortByRank []*pb.SourceSeries

CohortByRank implements sort.Interface for []*SourceSeries based on the rank score. Each source series data is keyed by the place dcid.

Note this has the same data type as SeriesByRank but is used to compare cohort instead of time series.

func (CohortByRank) Len

func (a CohortByRank) Len() int

func (CohortByRank) Less

func (a CohortByRank) Less(i, j int) bool

func (CohortByRank) Swap

func (a CohortByRank) Swap(i, j int)

type RankKey

type RankKey struct {
	MM   *string // MeasurementMethod
	OP   *string // ObservationPeriod
	Unit *string
}

RankKey represents keys used for ranking. Can use a nil pointer for wildcard match for any field that is a *string type.

type SeriesByRank

type SeriesByRank []*pb.SourceSeries

SeriesByRank implements sort.Interface for []*SourceSeries based on the rank score. Each source series data is keyed by the observation date.

This is the protobuf version of byRank.

func (SeriesByRank) Len

func (a SeriesByRank) Len() int

func (SeriesByRank) Less

func (a SeriesByRank) Less(i, j int) bool

func (SeriesByRank) Swap

func (a SeriesByRank) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL