UNPKG

hdsp2

Version:

High-Dimensional Space Projections

79 lines 3.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var MDSSGD_1 = require("./MDSSGD"); var Utils_1 = require("./Utils"); var test1 = [ [1, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 0, 1, 1, 1, 1], [0, 0, 0, 1, 0, 1, 0, 1] ]; var test1_distances = Utils_1.Utils.distance(test1); var threshold = 1e-5; var max_iter = 500; console.log("test1_distances", test1_distances); console.log("test1_distances shape: [".concat(test1_distances.length, ", ").concat(test1_distances[0].length, "]")); var test1_proj = MDSSGD_1.MDSSGD.project(test1, 2, threshold, max_iter); console.log("test1_proj shape: [".concat(test1_proj ? test1_proj.length : 0, ", ").concat(test1_proj ? test1_proj[0].length : 0, "]")); var test1_proj_dist; if (test1_proj !== null) { test1_proj_dist = Utils_1.Utils.distance(test1_proj); console.log("test1_proj_dist", test1_proj_dist); console.log("test1_proj_dist shape: [".concat(test1_proj_dist.length, ", ").concat(test1_proj_dist[0].length, "]")); } else { console.log("MDSSGD.project returned null"); } var square_test = [ [1, 0], [0, 1], [1, 1], [0, 0] ]; var square = MDSSGD_1.MDSSGD.project(square_test, 2, threshold, max_iter); var square_dist = Utils_1.Utils.distance(square_test); console.log("square_dist shape: [".concat(square_dist ? square_dist.length : 0, ", ").concat(square_dist ? square_dist[0].length : 0, "]")); console.log("square_dist", square_dist); var square_proj_dist; if (square !== null) { square_proj_dist = Utils_1.Utils.distance(square); console.log("square_proj_dist", square_proj_dist); console.log("square_proj_dist shape: [".concat(square_proj_dist.length, ", ").concat(square_proj_dist[0].length, "]")); } else { console.log("MDSSGD.project returned null"); } var ones = [ [1, 1], [1, 1] ]; var ones_dist = Utils_1.Utils.distance(ones); var ones_proj = MDSSGD_1.MDSSGD.project(ones, 2, threshold, max_iter); console.log("ones_proj", ones_proj); console.log("ones_dist shape: [".concat(ones_dist.length, ", ").concat(ones_dist[0].length, "]")); var ones_proj_dist; if (ones_proj !== null) { ones_proj_dist = Utils_1.Utils.distance(ones_proj); console.log("ones_proj shape: [".concat(ones_proj.length, ", ").concat(ones_proj[0].length, "]")); console.log("ones_proj_dist", ones_proj_dist); console.log("ones_proj_dist shape: [".concat(ones_proj_dist.length, ", ").concat(ones_proj_dist[0].length, "]")); } else { console.log("MDSSGD.project returned null"); } var randomValue = function () { return Math.random(); }; function generate2DMatrix(n, m) { var result = []; for (var i = 0; i < n; i++) { var row = []; for (var j = 0; j < m; j++) { row.push(randomValue()); } result.push(row); } return result; } var randomMatrix = generate2DMatrix(4, 10); console.log("randomMatrix distance: ", Utils_1.Utils.distance(randomMatrix)); var randomMatrix_proj = MDSSGD_1.MDSSGD.project(randomMatrix, 2, threshold, max_iter, 500); console.log("randomMatrix_proj distance: ", Utils_1.Utils.distance(randomMatrix_proj)); //# sourceMappingURL=TestMDSSGD.js.map