From c53bc52383ed07b8623c20d2ea6ce056942b3255 Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Mon, 5 Feb 2024 15:10:22 -0500 Subject: [PATCH 1/4] updating type --- packages/client/hmi-client/src/services/calibrate-workflow.ts | 4 ++-- packages/client/hmi-client/src/types/Types.ts | 2 +- .../hmiserver/models/mira/EntitySimilarityResult.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/client/hmi-client/src/services/calibrate-workflow.ts b/packages/client/hmi-client/src/services/calibrate-workflow.ts index 6b4a4fea4a..eeb0649f39 100644 --- a/packages/client/hmi-client/src/services/calibrate-workflow.ts +++ b/packages/client/hmi-client/src/services/calibrate-workflow.ts @@ -124,7 +124,7 @@ export const autoCalibrationMapping = async ( const result = [] as CalibrateMap[]; const allModelGroundings: string[] = []; const allDataGroundings: string[] = []; - const acceptableDistance = 0.7; + const acceptableDistance = 0.5; // Get all model groundings modelOptions.forEach((state) => { if (state.grounding?.identifiers) { @@ -145,7 +145,7 @@ export const autoCalibrationMapping = async ( const allSimilarity = await getEntitySimilarity(distinctModelGroundings, distinctDataGroundings); if (!allSimilarity) return result; - const filteredSim = allSimilarity.filter((ele) => ele.distance < acceptableDistance); + const filteredSim = allSimilarity.filter((ele) => ele.similarity < acceptableDistance); filteredSim.forEach((sim) => { // Find all states assosiated with this sim const validStates = modelOptions.filter((state) => { diff --git a/packages/client/hmi-client/src/types/Types.ts b/packages/client/hmi-client/src/types/Types.ts index 22e680a6f8..baef7f1e82 100644 --- a/packages/client/hmi-client/src/types/Types.ts +++ b/packages/client/hmi-client/src/types/Types.ts @@ -591,7 +591,7 @@ export interface DKG { export interface EntitySimilarityResult { source: string; target: string; - distance: number; + similarity: number; } export interface PermissionGroup { diff --git a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/mira/EntitySimilarityResult.java b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/mira/EntitySimilarityResult.java index ec411f762b..57b4455c57 100644 --- a/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/mira/EntitySimilarityResult.java +++ b/packages/server/src/main/java/software/uncharted/terarium/hmiserver/models/mira/EntitySimilarityResult.java @@ -10,5 +10,5 @@ public class EntitySimilarityResult { private String source; private String target; - private Float distance; + private Float similarity; } From 23e649fe9b6958379c7b3fb087bad67aa5eabdf7 Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Wed, 21 Feb 2024 10:54:29 -0500 Subject: [PATCH 2/4] updating dataset format parser --- packages/client/hmi-client/src/services/calibrate-workflow.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/services/calibrate-workflow.ts b/packages/client/hmi-client/src/services/calibrate-workflow.ts index 69d68c5afb..caf78fa338 100644 --- a/packages/client/hmi-client/src/services/calibrate-workflow.ts +++ b/packages/client/hmi-client/src/services/calibrate-workflow.ts @@ -135,7 +135,9 @@ export const autoCalibrationMapping = async ( }); // Get all data column groundings datasetOptions.forEach((col) => { - const dataGroundingList = Object.keys(col.metadata?.groundings?.identifiers); + const dataGroundingList = Object.entries(col.metadata?.groundings?.identifiers).map((ele) => + ele.join(':') + ); dataGroundingList.forEach((ele) => allDataGroundings.push(ele)); }); From c21bc73314bac860c330179b13f9c546ce36e535 Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Thu, 22 Feb 2024 09:06:45 -0500 Subject: [PATCH 3/4] getting dataoptions grounding better --- .../client/hmi-client/src/services/calibrate-workflow.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/client/hmi-client/src/services/calibrate-workflow.ts b/packages/client/hmi-client/src/services/calibrate-workflow.ts index caf78fa338..10b5707a7d 100644 --- a/packages/client/hmi-client/src/services/calibrate-workflow.ts +++ b/packages/client/hmi-client/src/services/calibrate-workflow.ts @@ -135,10 +135,11 @@ export const autoCalibrationMapping = async ( }); // Get all data column groundings datasetOptions.forEach((col) => { - const dataGroundingList = Object.entries(col.metadata?.groundings?.identifiers).map((ele) => - ele.join(':') - ); - dataGroundingList.forEach((ele) => allDataGroundings.push(ele)); + if (col.metadata?.groundings?.identifiers) { + Object.entries(col.metadata?.groundings?.identifiers) + .map((ele) => ele.join(':')) + .forEach((ele) => allDataGroundings.push(ele)); + } }); // take out duplicates: From 4b513f2d7c09c93214eea41096e64d5fb84a62f8 Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Thu, 22 Feb 2024 16:02:47 -0500 Subject: [PATCH 4/4] still need to make this 1:1 i know --- .../src/services/calibrate-workflow.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/client/hmi-client/src/services/calibrate-workflow.ts b/packages/client/hmi-client/src/services/calibrate-workflow.ts index 10b5707a7d..3a4a5256a2 100644 --- a/packages/client/hmi-client/src/services/calibrate-workflow.ts +++ b/packages/client/hmi-client/src/services/calibrate-workflow.ts @@ -147,22 +147,28 @@ export const autoCalibrationMapping = async ( const distinctDataGroundings = [...new Set(allDataGroundings)]; const allSimilarity = await getEntitySimilarity(distinctModelGroundings, distinctDataGroundings); if (!allSimilarity) return result; - - const filteredSim = allSimilarity.filter((ele) => ele.similarity < acceptableDistance); + // normalized cosine similarities + const filteredSim = allSimilarity.filter((ele) => ele.similarity > acceptableDistance); filteredSim.forEach((sim) => { // Find all states assosiated with this sim const validStates = modelOptions.filter((state) => { if (state.grounding?.identifiers) { - const modelTemp = Object.entries(state.grounding?.identifiers); - const modelGroundingList = modelTemp.map((ele) => ele.join(':')); + const modelGroundingList = Object.entries(state.grounding?.identifiers).map((ele) => + ele.join(':') + ); return modelGroundingList.includes(sim.source); } return false; }); // Find all columns assosiated with this sim const validCols = datasetOptions.filter((col) => { - const dataGroundingList = Object.keys(col.metadata?.groundings?.identifiers); - return dataGroundingList.includes(sim.target); + if (col.metadata?.groundings?.identifiers) { + const dataGroundingList = Object.entries(col.metadata?.groundings?.identifiers).map((ele) => + ele.join(':') + ); + return dataGroundingList.includes(sim.target); + } + return false; }); // For all states and columns that have short distances throw them into results validStates.forEach((state) => {