MCPcopy Index your code
hub / github.com/dreadl0ck/netcap / String

Method String

encoder/encoder.go:89–113  ·  view source on GitHub ↗

String handles encoding of categorical values according to the ValueEncoder configuration.

(field string, val string)

Source from the content-addressed store, hash-verified

87
88// String handles encoding of categorical values according to the ValueEncoder configuration.
89func (m *ValueEncoder) String(field string, val string) string {
90
91 sum := m.GetSummary(TypeString, field)
92
93 m.Lock()
94 i, ok := sum.UniqueStrings[val]
95 if !ok {
96 sum.UniqueStrings[val] = sum.Index
97 i = sum.Index
98 sum.Index++
99 }
100 m.Unlock()
101
102 if m.conf.NormalizeCategoricals {
103 if m.conf.ZScore {
104 return ZScore(i, sum)
105 }
106
107 if m.conf.MinMax {
108 return MinMax(i, sum)
109 }
110 }
111
112 return strconv.FormatFloat(i, 'f', precision, 64)
113}
114
115// Int handles encoding of integer values according to the ValueEncoder configuration.
116func (m *ValueEncoder) Int(field string, val int) string {

Calls 3

GetSummaryMethod · 0.95
ZScoreFunction · 0.85
MinMaxFunction · 0.85