Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/platform/learn/dataset.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/platform/learn/dataset.go |
| Original SHA-256 | c3d8663742cef243432d197449c930a7a04f1a9b0ab84b85b8c5b38e3484119f |
| Git blob SHA | 064724001bd594c918b7679060b92c1457823344 |
| Reading-copy SHA-256 | c3d8663742cef243432d197449c930a7a04f1a9b0ab84b85b8c5b38e3484119f |
Every recorded occurrence
These 10 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / internal/platform/learn/dataset.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/platform/learn/dataset.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓70 lines · 2.8 KB
package learn
import "sort"
// Result values a bid label can carry, mirroring the bid_outcomes.result CHECK. Only win and loss are decided
// labels a fit consumes; pending and no_bid are dropped by BuildDataset (an undecided bid is not a training
// example). These are the exact strings the ledger stores, so a raw scan maps straight onto them.
const (
ResultWin = "win"
ResultLoss = "loss"
ResultNoBid = "no_bid"
ResultPending = "pending"
)
// LabeledRow is one bid from the ledger: its decided Result and the named feature values of the segment the
// bid was for (market structure only, NEVER a protected attribute or a per candidate score). BuildDataset
// keeps only the rows whose Result is win or loss; everything else is an undecided bid and is dropped.
type LabeledRow struct {
Result string // one of the Result constants; only win and loss survive into the matrix
Features map[string]float64 // named segment feature values for this bid
}
// IsDecided reports whether a result is a decided label (a win or a loss). A pending or no_bid row carries no
// outcome to learn from and is excluded from the training matrix.
func IsDecided(result string) bool {
return result == ResultWin || result == ResultLoss
}
// BuildDataset assembles the labeled feature matrix from the decided bids. It drops every undecided row
// (pending, no_bid, or an unrecognized result), maps win to label 1 and loss to label 0, and returns the
// feature matrix x (one row per decided bid, one column per feature), the labels y, and the feature names in a
// STABLE order (the sorted union of every feature key across the decided rows). A row missing a feature the
// union contains contributes 0.0 for that column, so a ragged input still yields a rectangular matrix; the
// stable ordering means the same ledger always produces the same column layout, which the trainer relies on to
// pair a fitted coefficient with its feature name. No database, no I/O: this is pure over an in memory rowset.
func BuildDataset(rows []LabeledRow) (x [][]float64, y []int, featureNames []string) {
// The sorted union of feature names across the decided rows: the stable column layout.
nameSet := map[string]struct{}{}
for _, r := range rows {
if !IsDecided(r.Result) {
continue
}
for name := range r.Features {
nameSet[name] = struct{}{}
}
}
featureNames = make([]string, 0, len(nameSet))
for name := range nameSet {
featureNames = append(featureNames, name)
}
sort.Strings(featureNames)
for _, r := range rows {
if !IsDecided(r.Result) {
continue
}
row := make([]float64, len(featureNames))
for j, name := range featureNames {
row[j] = r.Features[name] // a missing feature is the zero column, the documented default
}
x = append(x, row)
if r.Result == ResultWin {
y = append(y, 1)
} else {
y = append(y, 0)
}
}
return x, y, featureNames
}