@datagrok/eda 1.1.25 → 1.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +5 -0
- package/CHANGELOG.md +12 -0
- package/README.md +1 -0
- package/dist/05e5e0770f54f07e9474.wasm +0 -0
- package/dist/111.js +2 -0
- package/dist/111.js.map +1 -0
- package/dist/153.js +2 -0
- package/dist/153.js.map +1 -0
- package/dist/23.js +2 -2
- package/dist/23.js.map +1 -0
- package/dist/234.js +2 -0
- package/dist/234.js.map +1 -0
- package/dist/242.js +2 -0
- package/dist/242.js.map +1 -0
- package/dist/260.js +2 -0
- package/dist/260.js.map +1 -0
- package/dist/317.js +2 -0
- package/dist/317.js.map +1 -0
- package/dist/33.js +2 -0
- package/dist/33.js.map +1 -0
- package/dist/348.js +2 -0
- package/dist/348.js.map +1 -0
- package/dist/377.js +2 -0
- package/dist/377.js.map +1 -0
- package/dist/412.js +2 -0
- package/dist/412.js.map +1 -0
- package/dist/415.js +2 -0
- package/dist/415.js.map +1 -0
- package/dist/531.js +2 -0
- package/dist/531.js.map +1 -0
- package/dist/583.js +2 -0
- package/dist/583.js.map +1 -0
- package/dist/589.js +2 -0
- package/dist/589.js.map +1 -0
- package/dist/603.js +2 -0
- package/dist/603.js.map +1 -0
- package/dist/656.js +2 -0
- package/dist/656.js.map +1 -0
- package/dist/682.js +2 -0
- package/dist/682.js.map +1 -0
- package/dist/705.js +2 -0
- package/dist/705.js.map +1 -0
- package/dist/731.js +2 -0
- package/dist/731.js.map +1 -0
- package/dist/738.js +3 -0
- package/dist/738.js.map +1 -0
- package/dist/763.js +2 -0
- package/dist/763.js.map +1 -0
- package/dist/778.js +2 -0
- package/dist/778.js.map +1 -0
- package/dist/783.js +2 -0
- package/dist/783.js.map +1 -0
- package/dist/793.js +2 -0
- package/dist/793.js.map +1 -0
- package/dist/907.js +2 -0
- package/dist/907.js.map +1 -0
- package/dist/91.js +2 -0
- package/dist/91.js.map +1 -0
- package/dist/950.js +2 -0
- package/dist/950.js.map +1 -0
- package/dist/package-test.js +2 -2
- package/dist/package-test.js.map +1 -0
- package/dist/package.js +2 -2
- package/dist/package.js.map +1 -0
- package/package.json +92 -92
- package/scripts/command.txt +1 -1
- package/scripts/func.json +1 -1
- package/scripts/module.json +1 -1
- package/src/missing-values-imputation/ui.ts +80 -66
- package/src/package.ts +288 -38
- package/src/pls/pls-tools.ts +16 -15
- package/src/regression.ts +232 -0
- package/src/svm.ts +78 -38
- package/tsconfig.json +4 -4
- package/wasm/EDA.js +65 -1
- package/wasm/EDA.wasm +0 -0
- package/wasm/EDAAPI.js +30 -0
- package/wasm/EDAForWebWorker.js +1 -1
- package/wasm/callWasm.js +384 -393
- package/wasm/regression-api.cpp +66 -0
- package/wasm/regression.h +128 -0
- package/wasm/workers/fitLinearRegressionParamsWithDataNormalizingWorker.js +13 -0
- package/wasm/workers/fitLinearRegressionParamsWorker.js +13 -0
- package/webpack.config.js +1 -1
- package/dist/208.js +0 -2
- package/dist/221.js +0 -2
- package/dist/231.js +0 -2
- package/dist/261.js +0 -2
- package/dist/282.js +0 -2
- package/dist/334.js +0 -2
- package/dist/356.js +0 -2
- package/dist/36.js +0 -2
- package/dist/367.js +0 -2
- package/dist/374.js +0 -2
- package/dist/40.js +0 -2
- package/dist/413.js +0 -2
- package/dist/42.js +0 -2
- package/dist/427.js +0 -2
- package/dist/467.js +0 -2
- package/dist/523.js +0 -3
- package/dist/533.js +0 -2
- package/dist/590.js +0 -2
- package/dist/65.js +0 -2
- package/dist/694.js +0 -2
- package/dist/729.js +0 -2
- package/dist/796.js +0 -2
- package/dist/902.js +0 -2
- package/dist/910.js +0 -2
- package/dist/972.js +0 -2
- package/dist/f5343e2c2e15952ce916.wasm +0 -0
- /package/dist/{523.js.LICENSE.txt → 738.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
2
|
+
"name": "@datagrok/eda",
|
|
3
|
+
"friendlyName": "EDA",
|
|
4
|
+
"version": "1.1.28",
|
|
5
|
+
"description": "Exploratory Data Analysis Tools",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@datagrok-libraries/math": "^1.1.10",
|
|
8
|
+
"@datagrok-libraries/ml": "^6.6.13",
|
|
9
|
+
"@datagrok-libraries/tutorials": "^1.3.6",
|
|
10
|
+
"@datagrok-libraries/utils": "^4.1.44",
|
|
11
|
+
"@keckelt/tsne": "^1.0.2",
|
|
12
|
+
"@webgpu/types": "^0.1.40",
|
|
13
|
+
"cash-dom": "^8.1.1",
|
|
14
|
+
"datagrok-api": "^1.20.0",
|
|
15
|
+
"dayjs": "^1.11.9",
|
|
16
|
+
"jstat": "^1.9.6",
|
|
17
|
+
"source-map-loader": "^4.0.1",
|
|
18
|
+
"umap-js": "^1.3.3",
|
|
19
|
+
"worker-loader": "latest"
|
|
20
|
+
},
|
|
21
|
+
"author": {
|
|
22
|
+
"name": "Viktor Makarichev",
|
|
23
|
+
"email": "vmakarichev@datagrok.ai"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^5.32.0",
|
|
27
|
+
"@typescript-eslint/parser": "^5.32.0",
|
|
28
|
+
"eslint": "^8.21.0",
|
|
29
|
+
"eslint-config-google": "^0.14.0",
|
|
30
|
+
"ts-loader": "latest",
|
|
31
|
+
"typescript": "latest",
|
|
32
|
+
"webpack": "latest",
|
|
33
|
+
"webpack-cli": "latest",
|
|
34
|
+
"css-loader": "latest",
|
|
35
|
+
"style-loader": "latest"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"link-all": "npm link datagrok-api @datagrok-libraries/utils @datagrok-libraries/tutorials",
|
|
39
|
+
"debug-eda": "webpack && grok publish",
|
|
40
|
+
"release-eda": "webpack && grok publish --release",
|
|
41
|
+
"build-eda": "webpack",
|
|
42
|
+
"build": "webpack",
|
|
43
|
+
"debug-eda-dev": "webpack && grok publish dev",
|
|
44
|
+
"release-eda-dev": "webpack && grok publish dev --release",
|
|
45
|
+
"debug-eda-local": "webpack && grok publish local",
|
|
46
|
+
"release-eda-local": "webpack && grok publish local --release",
|
|
47
|
+
"build-all": "npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/utils run build && npm --prefix ./../../libraries/tutorials run build && npm run build"
|
|
48
|
+
},
|
|
49
|
+
"canEdit": [
|
|
50
|
+
"Developers"
|
|
51
|
+
],
|
|
52
|
+
"canView": [
|
|
53
|
+
"All users"
|
|
54
|
+
],
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "https://github.com/datagrok-ai/public.git",
|
|
58
|
+
"directory": "packages/EDA"
|
|
59
|
+
},
|
|
60
|
+
"category": "Machine Learning",
|
|
61
|
+
"sources": [
|
|
62
|
+
"wasm/EDA.js"
|
|
63
|
+
],
|
|
64
|
+
"meta": {
|
|
65
|
+
"menu": {
|
|
66
|
+
"ML": {
|
|
67
|
+
"Tools": {
|
|
68
|
+
"Impute Missing Values...": null,
|
|
69
|
+
"Random Data...": null
|
|
70
|
+
},
|
|
71
|
+
"Cluster": {
|
|
72
|
+
"Cluster...": null,
|
|
73
|
+
"DBSCAN...": null
|
|
74
|
+
},
|
|
75
|
+
"Notebooks": {
|
|
76
|
+
"Browse Notebooks": null,
|
|
77
|
+
"Open in Notebook": null,
|
|
78
|
+
"New Notebook": null
|
|
79
|
+
},
|
|
80
|
+
"Models": {
|
|
81
|
+
"Browse Models": null,
|
|
82
|
+
"Train Model...": null,
|
|
83
|
+
"Apply Model...": null
|
|
84
|
+
},
|
|
85
|
+
"Analyse": {
|
|
86
|
+
"PCA...": null,
|
|
87
|
+
"ANOVA...": null,
|
|
88
|
+
"Multivariate Analysis...": null
|
|
89
|
+
},
|
|
90
|
+
"Reduce Dimensionality": null
|
|
91
|
+
}
|
|
92
|
+
}
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
}
|
|
94
|
+
}
|
package/scripts/command.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
em++ -O3 ../wasm/pcaExport.cpp ../wasm/PCA/PCA.cpp ../wasm/plsExport.cpp ../wasm/PLS/PLS.cpp ../wasm/svmApi.cpp -o ../wasm/EDA.js -s TOTAL_MEMORY=268435456 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXPORT_NAME="exportEDA" -s EXPORTED_FUNCTIONS=["_principalComponentAnalysis","_error","_partialLeastSquareRegression","_generateDataset","_normalizeDataset","_trainLSSVM","_predictByLSSVM","_trainAndAnalyzeLSSVM","_malloc","_free"] -s EXPORTED_RUNTIME_METHODS=["cwrap","ccall"] -sENVIRONMENT=web,worker
|
|
1
|
+
em++ -O3 ../wasm/pcaExport.cpp ../wasm/PCA/PCA.cpp ../wasm/plsExport.cpp ../wasm/PLS/PLS.cpp ../wasm/svmApi.cpp ../wasm/regression-api.cpp -o ../wasm/EDA.js -s TOTAL_MEMORY=268435456 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXPORT_NAME="exportEDA" -s EXPORTED_FUNCTIONS=["_principalComponentAnalysis","_error","_partialLeastSquareRegression","_generateDataset","_normalizeDataset","_trainLSSVM","_predictByLSSVM","_trainAndAnalyzeLSSVM","_fitLinearRegressionParamsWithDataNormalizing","_fitLinearRegressionParams","_malloc","_free"] -s EXPORTED_RUNTIME_METHODS=["cwrap","ccall"] -sENVIRONMENT=web,worker
|
package/scripts/func.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"pcaExport.cpp": {"principalComponentAnalysis": {"arguments": {"columns": {"type": "floatColumns"}, "componentsCount": {"type": "num"}, "centerNum": {"type": "num"}, "scaleNum": {"type": "num"}, "components": {"type": "newFloatColumns", "numOfRows": {"ref": "columns", "value": "numOfRows"}, "numOfColumns": {"ref": "componentsCount", "value": "data"}}}, "output": {"type": "tableFromColumns", "source": "components"}, "annotation": ["//name: principalComponentAnalysis", "//input: dataframe table", "//input: column_list columns", "//input: int componentsCount", "//input: int centerNum", "//input: int scaleNum", "//output: dataframe result "], "prototype": "principalComponentAnalysis(table, columns, componentsCount, centerNum, scaleNum)", "prototypeForWebWorker": "principalComponentAnalysisInWebWorker(table, columns, componentsCount, centerNum, scaleNum)", "callArgs": "[columns, componentsCount, centerNum, scaleNum]"}, "error": {"arguments": {"col1": {"type": "floatColumn"}, "col2": {"type": "floatColumn"}}, "output": {"type": "double", "source": "_callResult"}, "annotation": ["//name: error", "//input: dataframe df", "//input: column col1", "//input: column col2", "//output: double mad "], "prototype": "error(df, col1, col2)", "prototypeForWebWorker": "errorInWebWorker(df, col1, col2)", "callArgs": "[col1, col2]"}}, "PCA/PCA.cpp": {}, "plsExport.cpp": {"partialLeastSquareRegression": {"arguments": {"features": {"type": "floatColumns"}, "predict": {"type": "floatColumn"}, "componentsCount": {"type": "num"}, "prediction": {"type": "newFloatColumn", "numOfRows": {"ref": "predict", "value": "numOfRows"}}, "regressionCoefficients": {"type": "newFloatColumn", "numOfRows": {"ref": "features", "value": "numOfColumns"}}, "tScores": {"type": "newFloatColumns", "numOfRows": {"ref": "predict", "value": "numOfRows"}, "numOfColumns": {"ref": "componentsCount", "value": "data"}}, "uScores": {"type": "newFloatColumns", "numOfRows": {"ref": "predict", "value": "numOfRows"}, "numOfColumns": {"ref": "componentsCount", "value": "data"}}, "xLoadings": {"type": "newFloatColumns", "numOfRows": {"ref": "features", "value": "numOfColumns"}, "numOfColumns": {"ref": "componentsCount", "value": "data"}}, "yLoadings": {"type": "newFloatColumn", "numOfRows": {"ref": "componentsCount", "value": "data"}}}, "output": {"type": "objects", "source": "['prediction', 'regressionCoefficients', 'tScores', 'uScores', 'xLoadings', 'yLoadings']"}, "annotation": ["//name: partialLeastSquareRegression", "//input: dataframe table", "//input: column_list features", "//input: column predict", "//input: int componentsCount"], "prototype": "partialLeastSquareRegression(table, features, predict, componentsCount)", "prototypeForWebWorker": "partialLeastSquareRegressionInWebWorker(table, features, predict, componentsCount)", "callArgs": "[features, predict, componentsCount]"}}, "PLS/PLS.cpp": {}, "svmApi.cpp": {"generateDataset": {"arguments": {"kernel": {"type": "num"}, "kernelParams": {"type": "floatColumn"}, "samplesCount": {"type": "num"}, "featuresCount": {"type": "num"}, "min": {"type": "num"}, "max": {"type": "num"}, "violatorsPercentage": {"type": "num"}, "dataset": {"type": "newFloatColumns", "numOfRows": {"ref": "samplesCount", "value": "data"}, "numOfColumns": {"ref": "featuresCount", "value": "data"}}, "labels": {"type": "newFloatColumn", "numOfRows": {"ref": "samplesCount", "value": "data"}}}, "output": {"type": "objects", "source": "['dataset', 'labels']"}, "annotation": ["//name: generateDataset", "//input: int kernel", "//input: column kernelParams", "//input: int samplesCount", "//input: int featuresCount", "//input: double min", "//input: double max", "//input: double violatorsPercentage"], "prototype": "generateDataset(kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage)", "prototypeForWebWorker": "generateDatasetInWebWorker(kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage)", "callArgs": "[kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage]"}, "normalizeDataset": {"arguments": {"data": {"type": "floatColumns"}, "normalizedData": {"type": "newFloatColumns", "numOfRows": {"ref": "data", "value": "numOfColumns"}, "numOfColumns": {"ref": "data", "value": "numOfRows"}}, "means": {"type": "newFloatColumn", "numOfRows": {"ref": "data", "value": "numOfColumns"}}, "stdDevs": {"type": "newFloatColumn", "numOfRows": {"ref": "data", "value": "numOfColumns"}}}, "output": {"type": "objects", "source": "['normalizedData', 'means', 'stdDevs']"}, "annotation": ["//name: normalizeDataset", "//input: column_list data"], "prototype": "normalizeDataset(data)", "prototypeForWebWorker": "normalizeDatasetInWebWorker(data)", "callArgs": "[data]"}, "trainLSSVM": {"arguments": {"gamma": {"type": "num"}, "kernel": {"type": "num"}, "kernelParams": {"type": "floatColumn"}, "modelParamsCount": {"type": "num"}, "precomputedWeightsCount": {"type": "num"}, "dataset": {"type": "floatColumns"}, "labels": {"type": "floatColumn"}, "normalizedData": {"type": "newFloatColumns", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}, "numOfColumns": {"ref": "dataset", "value": "numOfRows"}}, "means": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}}, "stdDevs": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}}, "modelParams": {"type": "newFloatColumn", "numOfRows": {"ref": "modelParamsCount", "value": "data"}}, "precomputedWeights": {"type": "newFloatColumn", "numOfRows": {"ref": "precomputedWeightsCount", "value": "data"}}}, "output": {"type": "objects", "source": "['normalizedData', 'means', 'stdDevs', 'modelParams', 'precomputedWeights']"}, "annotation": ["//name: trainLSSVM", "//input: double gamma", "//input: int kernel", "//input: column kernelParams", "//input: int modelParamsCount", "//input: int precomputedWeightsCount", "//input: column_list dataset", "//input: column labels"], "prototype": "trainLSSVM(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels)", "prototypeForWebWorker": "trainLSSVMInWebWorker(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels)", "callArgs": "[gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels]"}, "predictByLSSVM": {"arguments": {"kernel": {"type": "num"}, "kernelParams": {"type": "floatColumn"}, "normalizedData": {"type": "floatColumns"}, "labels": {"type": "floatColumn"}, "means": {"type": "floatColumn"}, "stdDevs": {"type": "floatColumn"}, "modelParams": {"type": "floatColumn"}, "precomputedWeights": {"type": "floatColumn"}, "targetData": {"type": "floatColumns"}, "prediction": {"type": "newFloatColumn", "numOfRows": {"ref": "targetData", "value": "numOfRows"}}}, "output": {"type": "column", "source": "prediction"}, "annotation": ["//name: predictByLSSVM", "//input: int kernel", "//input: column kernelParams", "//input: column_list normalizedData", "//input: column labels", "//input: column means", "//input: column stdDevs", "//input: column modelParams", "//input: column precomputedWeights", "//input: column_list targetData", "//output: column prediction"], "prototype": "predictByLSSVM(kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData)", "prototypeForWebWorker": "predictByLSSVMInWebWorker(kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData)", "callArgs": "[kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData]"}, "trainAndAnalyzeLSSVM": {"arguments": {"gamma": {"type": "num"}, "kernel": {"type": "num"}, "kernelParams": {"type": "floatColumn"}, "modelParamsCount": {"type": "num"}, "precomputedWeightsCount": {"type": "num"}, "confusionMatrixElementsCount": {"type": "num"}, "dataset": {"type": "floatColumns"}, "labels": {"type": "floatColumn"}, "normalizedData": {"type": "newFloatColumns", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}, "numOfColumns": {"ref": "dataset", "value": "numOfRows"}}, "means": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}}, "stdDevs": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}}, "modelParams": {"type": "newFloatColumn", "numOfRows": {"ref": "modelParamsCount", "value": "data"}}, "precomputedWeights": {"type": "newFloatColumn", "numOfRows": {"ref": "precomputedWeightsCount", "value": "data"}}, "predictedLabels": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfRows"}}, "correctness": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfRows"}}, "consfusionMatrix": {"type": "newIntColumn", "numOfRows": {"ref": "confusionMatrixElementsCount", "value": "data"}}}, "output": {"type": "objects", "source": "['normalizedData', 'means', 'stdDevs', 'modelParams', 'precomputedWeights', 'predictedLabels', 'correctness', 'consfusionMatrix']"}, "annotation": ["//name: trainAndAnalyzeLSSVM", "//input: double gamma", "//input: int kernel", "//input: column kernelParams", "//input: int modelParamsCount", "//input: int precomputedWeightsCount", "//input: int confusionMatrixElementsCount", "//input: column_list dataset", "//input: column labels"], "prototype": "trainAndAnalyzeLSSVM(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels)", "prototypeForWebWorker": "trainAndAnalyzeLSSVMInWebWorker(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels)", "callArgs": "[gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels]"}}}
|
|
1
|
+
{"pcaExport.cpp": {"principalComponentAnalysis": {"arguments": {"columns": {"type": "floatColumns"}, "componentsCount": {"type": "num"}, "centerNum": {"type": "num"}, "scaleNum": {"type": "num"}, "components": {"type": "newFloatColumns", "numOfRows": {"ref": "columns", "value": "numOfRows"}, "numOfColumns": {"ref": "componentsCount", "value": "data"}}}, "output": {"type": "tableFromColumns", "source": "components"}, "annotation": ["//name: principalComponentAnalysis", "//input: dataframe table", "//input: column_list columns", "//input: int componentsCount", "//input: int centerNum", "//input: int scaleNum", "//output: dataframe result "], "prototype": "principalComponentAnalysis(table, columns, componentsCount, centerNum, scaleNum)", "prototypeForWebWorker": "principalComponentAnalysisInWebWorker(table, columns, componentsCount, centerNum, scaleNum)", "callArgs": "[columns, componentsCount, centerNum, scaleNum]"}, "error": {"arguments": {"col1": {"type": "floatColumn"}, "col2": {"type": "floatColumn"}}, "output": {"type": "double", "source": "_callResult"}, "annotation": ["//name: error", "//input: dataframe df", "//input: column col1", "//input: column col2", "//output: double mad "], "prototype": "error(df, col1, col2)", "prototypeForWebWorker": "errorInWebWorker(df, col1, col2)", "callArgs": "[col1, col2]"}}, "PCA/PCA.cpp": {}, "plsExport.cpp": {"partialLeastSquareRegression": {"arguments": {"features": {"type": "floatColumns"}, "predict": {"type": "floatColumn"}, "componentsCount": {"type": "num"}, "prediction": {"type": "newFloatColumn", "numOfRows": {"ref": "predict", "value": "numOfRows"}}, "regressionCoefficients": {"type": "newFloatColumn", "numOfRows": {"ref": "features", "value": "numOfColumns"}}, "tScores": {"type": "newFloatColumns", "numOfRows": {"ref": "predict", "value": "numOfRows"}, "numOfColumns": {"ref": "componentsCount", "value": "data"}}, "uScores": {"type": "newFloatColumns", "numOfRows": {"ref": "predict", "value": "numOfRows"}, "numOfColumns": {"ref": "componentsCount", "value": "data"}}, "xLoadings": {"type": "newFloatColumns", "numOfRows": {"ref": "features", "value": "numOfColumns"}, "numOfColumns": {"ref": "componentsCount", "value": "data"}}, "yLoadings": {"type": "newFloatColumn", "numOfRows": {"ref": "componentsCount", "value": "data"}}}, "output": {"type": "objects", "source": "['prediction', 'regressionCoefficients', 'tScores', 'uScores', 'xLoadings', 'yLoadings']"}, "annotation": ["//name: partialLeastSquareRegression", "//input: dataframe table", "//input: column_list features", "//input: column predict", "//input: int componentsCount"], "prototype": "partialLeastSquareRegression(table, features, predict, componentsCount)", "prototypeForWebWorker": "partialLeastSquareRegressionInWebWorker(table, features, predict, componentsCount)", "callArgs": "[features, predict, componentsCount]"}}, "PLS/PLS.cpp": {}, "svmApi.cpp": {"generateDataset": {"arguments": {"kernel": {"type": "num"}, "kernelParams": {"type": "floatColumn"}, "samplesCount": {"type": "num"}, "featuresCount": {"type": "num"}, "min": {"type": "num"}, "max": {"type": "num"}, "violatorsPercentage": {"type": "num"}, "dataset": {"type": "newFloatColumns", "numOfRows": {"ref": "samplesCount", "value": "data"}, "numOfColumns": {"ref": "featuresCount", "value": "data"}}, "labels": {"type": "newFloatColumn", "numOfRows": {"ref": "samplesCount", "value": "data"}}}, "output": {"type": "objects", "source": "['dataset', 'labels']"}, "annotation": ["//name: generateDataset", "//input: int kernel", "//input: column kernelParams", "//input: int samplesCount", "//input: int featuresCount", "//input: double min", "//input: double max", "//input: double violatorsPercentage"], "prototype": "generateDataset(kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage)", "prototypeForWebWorker": "generateDatasetInWebWorker(kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage)", "callArgs": "[kernel, kernelParams, samplesCount, featuresCount, min, max, violatorsPercentage]"}, "normalizeDataset": {"arguments": {"data": {"type": "floatColumns"}, "normalizedData": {"type": "newFloatColumns", "numOfRows": {"ref": "data", "value": "numOfColumns"}, "numOfColumns": {"ref": "data", "value": "numOfRows"}}, "means": {"type": "newFloatColumn", "numOfRows": {"ref": "data", "value": "numOfColumns"}}, "stdDevs": {"type": "newFloatColumn", "numOfRows": {"ref": "data", "value": "numOfColumns"}}}, "output": {"type": "objects", "source": "['normalizedData', 'means', 'stdDevs']"}, "annotation": ["//name: normalizeDataset", "//input: column_list data"], "prototype": "normalizeDataset(data)", "prototypeForWebWorker": "normalizeDatasetInWebWorker(data)", "callArgs": "[data]"}, "trainLSSVM": {"arguments": {"gamma": {"type": "num"}, "kernel": {"type": "num"}, "kernelParams": {"type": "floatColumn"}, "modelParamsCount": {"type": "num"}, "precomputedWeightsCount": {"type": "num"}, "dataset": {"type": "floatColumns"}, "labels": {"type": "floatColumn"}, "normalizedData": {"type": "newFloatColumns", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}, "numOfColumns": {"ref": "dataset", "value": "numOfRows"}}, "means": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}}, "stdDevs": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}}, "modelParams": {"type": "newFloatColumn", "numOfRows": {"ref": "modelParamsCount", "value": "data"}}, "precomputedWeights": {"type": "newFloatColumn", "numOfRows": {"ref": "precomputedWeightsCount", "value": "data"}}}, "output": {"type": "objects", "source": "['normalizedData', 'means', 'stdDevs', 'modelParams', 'precomputedWeights']"}, "annotation": ["//name: trainLSSVM", "//input: double gamma", "//input: int kernel", "//input: column kernelParams", "//input: int modelParamsCount", "//input: int precomputedWeightsCount", "//input: column_list dataset", "//input: column labels"], "prototype": "trainLSSVM(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels)", "prototypeForWebWorker": "trainLSSVMInWebWorker(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels)", "callArgs": "[gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, dataset, labels]"}, "predictByLSSVM": {"arguments": {"kernel": {"type": "num"}, "kernelParams": {"type": "floatColumn"}, "normalizedData": {"type": "floatColumns"}, "labels": {"type": "floatColumn"}, "means": {"type": "floatColumn"}, "stdDevs": {"type": "floatColumn"}, "modelParams": {"type": "floatColumn"}, "precomputedWeights": {"type": "floatColumn"}, "targetData": {"type": "floatColumns"}, "prediction": {"type": "newFloatColumn", "numOfRows": {"ref": "targetData", "value": "numOfRows"}}}, "output": {"type": "column", "source": "prediction"}, "annotation": ["//name: predictByLSSVM", "//input: int kernel", "//input: column kernelParams", "//input: column_list normalizedData", "//input: column labels", "//input: column means", "//input: column stdDevs", "//input: column modelParams", "//input: column precomputedWeights", "//input: column_list targetData", "//output: column prediction"], "prototype": "predictByLSSVM(kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData)", "prototypeForWebWorker": "predictByLSSVMInWebWorker(kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData)", "callArgs": "[kernel, kernelParams, normalizedData, labels, means, stdDevs, modelParams, precomputedWeights, targetData]"}, "trainAndAnalyzeLSSVM": {"arguments": {"gamma": {"type": "num"}, "kernel": {"type": "num"}, "kernelParams": {"type": "floatColumn"}, "modelParamsCount": {"type": "num"}, "precomputedWeightsCount": {"type": "num"}, "confusionMatrixElementsCount": {"type": "num"}, "dataset": {"type": "floatColumns"}, "labels": {"type": "floatColumn"}, "normalizedData": {"type": "newFloatColumns", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}, "numOfColumns": {"ref": "dataset", "value": "numOfRows"}}, "means": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}}, "stdDevs": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfColumns"}}, "modelParams": {"type": "newFloatColumn", "numOfRows": {"ref": "modelParamsCount", "value": "data"}}, "precomputedWeights": {"type": "newFloatColumn", "numOfRows": {"ref": "precomputedWeightsCount", "value": "data"}}, "predictedLabels": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfRows"}}, "correctness": {"type": "newFloatColumn", "numOfRows": {"ref": "dataset", "value": "numOfRows"}}, "consfusionMatrix": {"type": "newIntColumn", "numOfRows": {"ref": "confusionMatrixElementsCount", "value": "data"}}}, "output": {"type": "objects", "source": "['normalizedData', 'means', 'stdDevs', 'modelParams', 'precomputedWeights', 'predictedLabels', 'correctness', 'consfusionMatrix']"}, "annotation": ["//name: trainAndAnalyzeLSSVM", "//input: double gamma", "//input: int kernel", "//input: column kernelParams", "//input: int modelParamsCount", "//input: int precomputedWeightsCount", "//input: int confusionMatrixElementsCount", "//input: column_list dataset", "//input: column labels"], "prototype": "trainAndAnalyzeLSSVM(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels)", "prototypeForWebWorker": "trainAndAnalyzeLSSVMInWebWorker(gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels)", "callArgs": "[gamma, kernel, kernelParams, modelParamsCount, precomputedWeightsCount, confusionMatrixElementsCount, dataset, labels]"}}, "regression-api.cpp": {"fitLinearRegressionParamsWithDataNormalizing": {"arguments": {"features": {"type": "floatColumns"}, "featureAvgs": {"type": "floatColumn"}, "featureStdDevs": {"type": "floatColumn"}, "targets": {"type": "floatColumn"}, "targetsAvg": {"type": "num"}, "targetsStdDev": {"type": "num"}, "paramsCount": {"type": "num"}, "params": {"type": "newFloatColumn", "numOfRows": {"ref": "paramsCount", "value": "data"}}}, "output": {"type": "column", "source": "params"}, "annotation": ["//name: fitLinearRegressionParamsWithDataNormalizing", "//input: column_list features", "//input: column featureAvgs", "//input: column featureStdDevs", "//input: column targets", "//input: double targetsAvg", "//input: double targetsStdDev", "//input: int paramsCount", "//output: column params"], "prototype": "fitLinearRegressionParamsWithDataNormalizing(features, featureAvgs, featureStdDevs, targets, targetsAvg, targetsStdDev, paramsCount)", "prototypeForWebWorker": "fitLinearRegressionParamsWithDataNormalizingInWebWorker(features, featureAvgs, featureStdDevs, targets, targetsAvg, targetsStdDev, paramsCount)", "callArgs": "[features, featureAvgs, featureStdDevs, targets, targetsAvg, targetsStdDev, paramsCount]"}, "fitLinearRegressionParams": {"arguments": {"features": {"type": "floatColumns"}, "targets": {"type": "floatColumn"}, "paramsCount": {"type": "num"}, "params": {"type": "newFloatColumn", "numOfRows": {"ref": "paramsCount", "value": "data"}}}, "output": {"type": "column", "source": "params"}, "annotation": ["//name: fitLinearRegressionParams", "//input: column_list features", "//input: column targets", "//input: int paramsCount", "//output: column params"], "prototype": "fitLinearRegressionParams(features, targets, paramsCount)", "prototypeForWebWorker": "fitLinearRegressionParamsInWebWorker(features, targets, paramsCount)", "callArgs": "[features, targets, paramsCount]"}}}
|
package/scripts/module.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "EDA",
|
|
3
3
|
"folder": "../wasm",
|
|
4
|
-
"source": ["pcaExport.cpp", "PCA/PCA.cpp", "plsExport.cpp", "PLS/PLS.cpp", "svmApi.cpp"],
|
|
4
|
+
"source": ["pcaExport.cpp", "PCA/PCA.cpp", "plsExport.cpp", "PLS/PLS.cpp", "svmApi.cpp", "regression-api.cpp"],
|
|
5
5
|
"optimizationMode": "-O3",
|
|
6
6
|
"packageFile": "../src/package.ts",
|
|
7
7
|
"packageJsonFile": "../package.json",
|
|
@@ -2,51 +2,51 @@ import * as grok from 'datagrok-api/grok';
|
|
|
2
2
|
import * as ui from 'datagrok-api/ui';
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
impute, getMissingValsIndices, areThereFails, imputeFailed
|
|
5
|
+
import {TITLE, KNN_IMPUTER, ERROR_MSG, HINT} from './ui-constants';
|
|
6
|
+
import {SUPPORTED_COLUMN_TYPES, METRIC_TYPE, DISTANCE_TYPE, MetricInfo, DEFAULT, MIN_NEIGHBORS,
|
|
7
|
+
impute, getMissingValsIndices, areThereFails, imputeFailed} from './knn-imputer';
|
|
8
8
|
|
|
9
9
|
/** Setting of the feature metric inputs */
|
|
10
10
|
type FeatureInputSettings = {
|
|
11
11
|
defaultWeight: number,
|
|
12
12
|
defaultMetric: METRIC_TYPE,
|
|
13
|
-
availableMetrics: METRIC_TYPE[],
|
|
13
|
+
availableMetrics: METRIC_TYPE[],
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/** Return default setting of the feature metric inputs */
|
|
17
17
|
function getFeatureInputSettings(type: DG.COLUMN_TYPE): FeatureInputSettings {
|
|
18
18
|
switch (type) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
case DG.COLUMN_TYPE.STRING:
|
|
20
|
+
case DG.COLUMN_TYPE.DATE_TIME:
|
|
21
|
+
return {
|
|
22
|
+
defaultWeight: DEFAULT.WEIGHT,
|
|
23
|
+
defaultMetric: METRIC_TYPE.ONE_HOT,
|
|
24
|
+
availableMetrics: [METRIC_TYPE.ONE_HOT],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
case DG.COLUMN_TYPE.INT:
|
|
28
|
+
case DG.COLUMN_TYPE.FLOAT:
|
|
29
|
+
case DG.COLUMN_TYPE.QNUM:
|
|
30
|
+
return {
|
|
31
|
+
defaultWeight: DEFAULT.WEIGHT,
|
|
32
|
+
defaultMetric: METRIC_TYPE.DIFFERENCE,
|
|
33
|
+
availableMetrics: [METRIC_TYPE.DIFFERENCE, METRIC_TYPE.ONE_HOT],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
default:
|
|
37
|
+
throw new Error(ERROR_MSG.UNSUPPORTED_COLUMN_TYPE);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/** Run the KNN missing values imputer */
|
|
42
|
-
export function runKNNImputer(): void {
|
|
42
|
+
export async function runKNNImputer(df?: DG.DataFrame): Promise<void> {
|
|
43
43
|
/** current dataframe */
|
|
44
|
-
|
|
44
|
+
df ??= grok.shell.t;
|
|
45
45
|
|
|
46
46
|
if (df === null) {
|
|
47
47
|
grok.shell.warning(ERROR_MSG.NO_DATAFRAME);
|
|
48
48
|
return;
|
|
49
|
-
}
|
|
49
|
+
}
|
|
50
50
|
|
|
51
51
|
/** columns with missing values */
|
|
52
52
|
const colsWithMissingVals = [] as DG.Column[];
|
|
@@ -84,53 +84,54 @@ export function runKNNImputer(): void {
|
|
|
84
84
|
|
|
85
85
|
// In-place components
|
|
86
86
|
let inPlace = DEFAULT.IN_PLACE > 0;
|
|
87
|
-
const inPlaceInput = ui.
|
|
87
|
+
const inPlaceInput = ui.input.bool(TITLE.IN_PLACE, {value: inPlace,
|
|
88
|
+
onValueChanged: () => {inPlace = inPlaceInput.value ?? false;}});
|
|
88
89
|
inPlaceInput.setTooltip(HINT.IN_PLACE);
|
|
89
90
|
|
|
90
91
|
// Keep empty feature
|
|
91
92
|
let keepEmpty = DEFAULT.KEEP_EMPTY > 0;
|
|
92
|
-
const keepEmptyInput = ui.
|
|
93
|
+
const keepEmptyInput = ui.input.bool(TITLE.KEEP_EMPTY, {value: keepEmpty,
|
|
94
|
+
onValueChanged: () => {keepEmpty = keepEmptyInput.value ?? false;}});
|
|
93
95
|
keepEmptyInput.setTooltip(HINT.KEEP_EMPTY);
|
|
94
96
|
|
|
95
97
|
// Neighbors components
|
|
96
98
|
let neighbors = DEFAULT.NEIGHBORS;
|
|
97
|
-
const neighborsInput = ui.
|
|
99
|
+
const neighborsInput = ui.input.int(TITLE.NEIGHBORS, {value: neighbors, onValueChanged: () => {
|
|
98
100
|
const val = neighborsInput.value;
|
|
99
101
|
if (val === null)
|
|
100
102
|
neighborsInput.value = neighbors;
|
|
101
|
-
else if (val >= MIN_NEIGHBORS)
|
|
103
|
+
else if (val >= MIN_NEIGHBORS)
|
|
102
104
|
neighbors = val;
|
|
103
105
|
else
|
|
104
106
|
neighborsInput.value = neighbors;
|
|
105
|
-
});
|
|
107
|
+
}});
|
|
106
108
|
neighborsInput.setTooltip(HINT.NEIGHBORS);
|
|
107
109
|
|
|
108
110
|
// Distance components
|
|
109
111
|
let distType = DISTANCE_TYPE.EUCLIDEAN;
|
|
110
|
-
const distTypeInput = ui.
|
|
111
|
-
() => distType = distTypeInput.value ?? DISTANCE_TYPE.EUCLIDEAN)
|
|
112
|
+
const distTypeInput: DG.ChoiceInput<DISTANCE_TYPE> = ui.input.choice(TITLE.DISTANCE, {value: distType,
|
|
113
|
+
items: [DISTANCE_TYPE.EUCLIDEAN, DISTANCE_TYPE.MANHATTAN], onValueChanged: () => distType = distTypeInput.value ?? DISTANCE_TYPE.EUCLIDEAN}) as DG.ChoiceInput<DISTANCE_TYPE>;
|
|
112
114
|
distTypeInput.setTooltip(HINT.DISTANCE);
|
|
113
115
|
|
|
114
116
|
// Target columns components (cols with missing values to be imputed)
|
|
115
117
|
let targetColNames = colsWithMissingVals.map((col) => col.name);
|
|
116
|
-
const targetColInput = ui.
|
|
117
|
-
targetColNames = targetColInput.value.map((col) => col.name);
|
|
118
|
+
const targetColInput = ui.input.columns(TITLE.COLUMNS, {table: df, onValueChanged: () => {
|
|
119
|
+
targetColNames = targetColInput.value.map((col) => col.name);
|
|
118
120
|
checkApplicability();
|
|
119
|
-
},
|
|
121
|
+
}, available: availableTargetColsNames, checked: availableTargetColsNames});
|
|
120
122
|
targetColInput.setTooltip(HINT.TARGET);
|
|
121
123
|
|
|
122
124
|
// Feature columns components
|
|
123
125
|
let selectedFeatureColNames = availableFeatureColsNames as string[];
|
|
124
|
-
const featuresInput = ui.
|
|
126
|
+
const featuresInput = ui.input.columns(TITLE.FEATURES, {table: df, onValueChanged: () => {
|
|
125
127
|
selectedFeatureColNames = featuresInput.value.map((col) => col.name);
|
|
126
128
|
|
|
127
129
|
if (selectedFeatureColNames.length > 0) {
|
|
128
130
|
checkApplicability();
|
|
129
|
-
metricInfoInputs.forEach((div, name) => div.hidden = !selectedFeatureColNames.includes(name));
|
|
130
|
-
}
|
|
131
|
-
else
|
|
131
|
+
metricInfoInputs.forEach((div, name) => div.hidden = !selectedFeatureColNames.includes(name));
|
|
132
|
+
} else
|
|
132
133
|
hideWidgets();
|
|
133
|
-
},
|
|
134
|
+
}, available: availableFeatureColsNames, checked: availableFeatureColsNames});
|
|
134
135
|
featuresInput.setTooltip(HINT.FEATURES);
|
|
135
136
|
|
|
136
137
|
/** Hide widgets (use if run is not applicable) */
|
|
@@ -155,14 +156,15 @@ export function runKNNImputer(): void {
|
|
|
155
156
|
|
|
156
157
|
/** Check applicability of the imputation */
|
|
157
158
|
const checkApplicability = () => {
|
|
158
|
-
showWidgets();
|
|
159
|
-
|
|
159
|
+
showWidgets();
|
|
160
|
+
|
|
160
161
|
if (selectedFeatureColNames.length === 1) {
|
|
161
162
|
targetColNames.forEach((name) => {
|
|
162
163
|
if (selectedFeatureColNames[0] === name) {
|
|
163
164
|
hideWidgets();
|
|
164
165
|
grok.shell.warning(`${ERROR_MSG.ONE_FEATURE_SELECTED} the column '${name}'`);
|
|
165
|
-
|
|
166
|
+
}
|
|
167
|
+
});
|
|
166
168
|
}
|
|
167
169
|
};
|
|
168
170
|
|
|
@@ -173,25 +175,26 @@ export function runKNNImputer(): void {
|
|
|
173
175
|
metricsDiv.style.overflow = 'auto';
|
|
174
176
|
|
|
175
177
|
// Create metrics UI
|
|
176
|
-
availableFeatureColsNames.forEach((name) => {
|
|
178
|
+
availableFeatureColsNames.forEach((name) => {
|
|
177
179
|
// initialization
|
|
178
180
|
const type = df!.col(name)!.type as DG.COLUMN_TYPE;
|
|
179
181
|
const settings = getFeatureInputSettings(type);
|
|
180
182
|
featuresMetrics.set(name, {weight: settings.defaultWeight, type: settings.defaultMetric});
|
|
181
183
|
|
|
182
184
|
// distance input
|
|
183
|
-
const distTypeInput = ui.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
185
|
+
const distTypeInput = ui.input.choice(name, {value: settings.defaultMetric,
|
|
186
|
+
items: settings.availableMetrics, onValueChanged: () => {
|
|
187
|
+
const distInfo = featuresMetrics.get(name) ?? {weight: settings.defaultWeight, type: settings.defaultMetric};
|
|
188
|
+
distInfo.type = distTypeInput.value ?? settings.defaultMetric;
|
|
189
|
+
featuresMetrics.set(name, distInfo);
|
|
190
|
+
}});
|
|
188
191
|
distTypeInput.root.style.width = '50%';
|
|
189
192
|
distTypeInput.setTooltip(HINT.METRIC);
|
|
190
193
|
distTypeInput.root.hidden = true; // this input will be used further
|
|
191
194
|
|
|
192
195
|
// The following should provide a slider (see th bug https://reddata.atlassian.net/browse/GROK-14431)
|
|
193
196
|
// @ts-ignore
|
|
194
|
-
const prop = DG.Property.fromOptions({
|
|
197
|
+
const prop = DG.Property.fromOptions({'name': name, 'inputType': 'Float', 'min': 0, 'max': 10, 'showSlider': true, 'step': 1});
|
|
195
198
|
const weightInput = ui.input.forProperty(prop);
|
|
196
199
|
weightInput.value = settings.defaultWeight;
|
|
197
200
|
weightInput.onChanged(() => {
|
|
@@ -200,7 +203,7 @@ export function runKNNImputer(): void {
|
|
|
200
203
|
featuresMetrics.set(name, distInfo);
|
|
201
204
|
});
|
|
202
205
|
weightInput.setTooltip(HINT.WEIGHT);
|
|
203
|
-
|
|
206
|
+
|
|
204
207
|
const div = ui.divH([distTypeInput.root, weightInput.root]);
|
|
205
208
|
metricInfoInputs.set(name, div);
|
|
206
209
|
metricsDiv.append(div);
|
|
@@ -214,11 +217,27 @@ export function runKNNImputer(): void {
|
|
|
214
217
|
keepEmptyInput.root.hidden = !areThereFails(targetColNames, selectedFeatureColNames, misValsInds);
|
|
215
218
|
|
|
216
219
|
// Icon showing/hiding metrics UI
|
|
217
|
-
const settingsIcon = ui.icons.settings(() => {
|
|
220
|
+
const settingsIcon = ui.icons.settings(() => {metricsDiv.hidden = !metricsDiv.hidden;}, HINT.METRIC_SETTINGS);
|
|
218
221
|
|
|
219
222
|
const distDiv = ui.divH([distTypeInput.root, settingsIcon]);
|
|
220
223
|
|
|
221
|
-
|
|
224
|
+
let resolve: (value: void | PromiseLike<void>) => void;
|
|
225
|
+
let reject: (reason?: any) => void;
|
|
226
|
+
let okClicked = false;
|
|
227
|
+
const promise = new Promise<void>((res, rej) => {
|
|
228
|
+
resolve = res;
|
|
229
|
+
reject = rej;
|
|
230
|
+
});
|
|
231
|
+
dlg.add(targetColInput)
|
|
232
|
+
.add(featuresInput)
|
|
233
|
+
.add(distDiv)
|
|
234
|
+
.add(metricsDiv)
|
|
235
|
+
.add(neighborsInput)
|
|
236
|
+
.add(inPlaceInput)
|
|
237
|
+
.add(keepEmptyInput)
|
|
238
|
+
.show()
|
|
239
|
+
.onOK(() => {
|
|
240
|
+
okClicked = true;
|
|
222
241
|
dlg.close();
|
|
223
242
|
availableFeatureColsNames.filter((name) => !selectedFeatureColNames.includes(name)).forEach((name) => featuresMetrics.delete(name));
|
|
224
243
|
|
|
@@ -227,20 +246,15 @@ export function runKNNImputer(): void {
|
|
|
227
246
|
|
|
228
247
|
if (!keepEmpty)
|
|
229
248
|
imputeFailed(df!, failedToImpute);
|
|
230
|
-
|
|
231
|
-
catch (err) {
|
|
249
|
+
resolve();
|
|
250
|
+
} catch (err) {
|
|
232
251
|
if (err instanceof Error)
|
|
233
252
|
grok.shell.error(`${ERROR_MSG.KNN_FAILS}: ${err.message}`);
|
|
234
253
|
else
|
|
235
254
|
grok.shell.error(`${ERROR_MSG.KNN_FAILS}: ${ERROR_MSG.CORE_ISSUE}`);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
.
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
.add(metricsDiv)
|
|
242
|
-
.add(neighborsInput)
|
|
243
|
-
.add(inPlaceInput)
|
|
244
|
-
.add(keepEmptyInput)
|
|
245
|
-
.show();
|
|
255
|
+
reject(err);
|
|
256
|
+
}
|
|
257
|
+
}).onClose.subscribe(() => !okClicked && reject());
|
|
258
|
+
|
|
259
|
+
return promise;
|
|
246
260
|
} // runKNNImputer
|