Skip to content

Commit dad8edb

Browse files
RyanMullinsLIT team
authored and
LIT team
committed
Fixes bug in use of regression and classification source prefixes in
DataService and unifies the separator between data in column names. PiperOrigin-RevId: 457953370
1 parent 9a1198d commit dad8edb

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lit_nlp/client/services/data_service.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ export class DataService extends LitService {
120120
this.setValuesForNewDatapoints(newDatapoints));
121121
}
122122

123+
/**
124+
* Get the column name given a model, key, and optional type.
125+
*
126+
* Note that colons are used as separators between these three pieces of data,
127+
* so none of these values should contain a colon.
128+
*/
123129
getColumnName(model: string, predKey: string, type?: CalculatedColumnType) {
124-
let columnName = `${model}:${predKey}`;
125-
if (type != null) {
126-
columnName += ` ${type}`;
127-
}
128-
return columnName;
130+
return `${model}:${predKey}${type != null ? `:${type}` : ''}`;
129131
}
130132

131133
/**
@@ -161,7 +163,7 @@ export class DataService extends LitService {
161163
(result: ClassificationResults) => result[key].predicted_class);
162164
const correctness = classificationResults.map(
163165
(result: ClassificationResults) => result[key].correct);
164-
const source = `CLASSIFICATION_SOURCE_PREFIX:${model}`;
166+
const source = `${CLASSIFICATION_SOURCE_PREFIX}:${model}`;
165167
this.addColumnFromList(
166168
scores, data, scoreFeatName,
167169
this.appState.createLitType('MulticlassPreds', false), source);
@@ -212,7 +214,7 @@ export class DataService extends LitService {
212214
const sqErrors = regressionResults.map(
213215
(result: RegressionResults) => result[key].squared_error);
214216
const dataType = this.appState.createLitType('Scalar', false);
215-
const source = `REGRESSION_SOURCE_PREFIX:${model}`;
217+
const source = `${REGRESSION_SOURCE_PREFIX}:${model}`;
216218
this.addColumnFromList(scores, data, scoreFeatName, dataType, source);
217219
if (output[key].parent != null) {
218220
this.addColumnFromList(errors, data, errorFeatName, dataType, source);

0 commit comments

Comments
 (0)