@formant/ava 3.4.1-formant
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/README.md +72 -0
- package/dist/ava.min.js +1 -0
- package/esm/advisor/advise-pipeline/advicesForChart.js +68 -0
- package/esm/advisor/advise-pipeline/data-to-advices.js +241 -0
- package/esm/advisor/advise-pipeline/index.js +1 -0
- package/esm/advisor/advise-pipeline/spec-mapping.js +500 -0
- package/esm/advisor/advisor.js +35 -0
- package/esm/advisor/constants.js +13 -0
- package/esm/advisor/index.js +2 -0
- package/esm/advisor/lint-pipeline/check-rules.js +43 -0
- package/esm/advisor/lint-pipeline/getChartType.js +109 -0
- package/esm/advisor/lint-pipeline/index.js +0 -0
- package/esm/advisor/lint-pipeline/lintRules.js +32 -0
- package/esm/advisor/ruler/index.js +74 -0
- package/esm/advisor/ruler/rules/aggregation-single-row.js +21 -0
- package/esm/advisor/ruler/rules/all-can-be-table.js +17 -0
- package/esm/advisor/ruler/rules/bar-series-qty.js +36 -0
- package/esm/advisor/ruler/rules/bar-without-axis-min.js +41 -0
- package/esm/advisor/ruler/rules/constants.js +6 -0
- package/esm/advisor/ruler/rules/data-check.js +40 -0
- package/esm/advisor/ruler/rules/data-field-qty.js +26 -0
- package/esm/advisor/ruler/rules/diff-pie-sector.js +33 -0
- package/esm/advisor/ruler/rules/index.js +68 -0
- package/esm/advisor/ruler/rules/landscape-or-portrait.js +40 -0
- package/esm/advisor/ruler/rules/limit-series.js +47 -0
- package/esm/advisor/ruler/rules/line-field-time-ordinal.js +25 -0
- package/esm/advisor/ruler/rules/no-redundant-field.js +32 -0
- package/esm/advisor/ruler/rules/nominal-enum-combinatorial.js +54 -0
- package/esm/advisor/ruler/rules/purpose-check.js +27 -0
- package/esm/advisor/ruler/rules/series-qty-limit.js +34 -0
- package/esm/advisor/ruler/rules/x-axis-line-fading.js +41 -0
- package/esm/advisor/ruler/types.js +1 -0
- package/esm/advisor/ruler/utils.js +54 -0
- package/esm/advisor/types.js +1 -0
- package/esm/advisor/utils/clone.js +32 -0
- package/esm/advisor/utils/compare.js +14 -0
- package/esm/advisor/utils/computeScore.js +25 -0
- package/esm/advisor/utils/deep-mix.js +76 -0
- package/esm/advisor/utils/hasSubset.js +3 -0
- package/esm/advisor/utils/index.js +8 -0
- package/esm/advisor/utils/inferDataType.js +70 -0
- package/esm/advisor/utils/intersects.js +3 -0
- package/esm/advisor/utils/isNil.js +4 -0
- package/esm/ckb/base.js +1310 -0
- package/esm/ckb/ckb.js +55 -0
- package/esm/ckb/constants.js +197 -0
- package/esm/ckb/i18n/index.js +23 -0
- package/esm/ckb/i18n/types.js +1 -0
- package/esm/ckb/i18n/zh-CN.js +525 -0
- package/esm/ckb/index.js +14 -0
- package/esm/ckb/types.js +1 -0
- package/esm/common/types.js +1 -0
- package/esm/data/analysis/field/index.js +336 -0
- package/esm/data/analysis/field/types.js +1 -0
- package/esm/data/analysis/graph/index.js +170 -0
- package/esm/data/analysis/graph/types.js +1 -0
- package/esm/data/analysis/index.js +1 -0
- package/esm/data/analysis/types.js +1 -0
- package/esm/data/dataset/field/baseFrame.js +76 -0
- package/esm/data/dataset/field/dataFrame.js +556 -0
- package/esm/data/dataset/field/index.js +3 -0
- package/esm/data/dataset/field/series.js +149 -0
- package/esm/data/dataset/field/types.js +1 -0
- package/esm/data/dataset/field/utils.js +58 -0
- package/esm/data/dataset/graph/index.js +186 -0
- package/esm/data/dataset/graph/types.js +1 -0
- package/esm/data/dataset/graph/utils.js +15 -0
- package/esm/data/dataset/index.js +1 -0
- package/esm/data/dataset/types.js +1 -0
- package/esm/data/index.js +5 -0
- package/esm/data/statistics/IQR.js +49 -0
- package/esm/data/statistics/base.js +248 -0
- package/esm/data/statistics/bayesian.js +25 -0
- package/esm/data/statistics/buishand-u.js +19 -0
- package/esm/data/statistics/caches.js +28 -0
- package/esm/data/statistics/cdf.js +25 -0
- package/esm/data/statistics/constants.js +12 -0
- package/esm/data/statistics/index.js +7 -0
- package/esm/data/statistics/lowess.js +80 -0
- package/esm/data/statistics/mannkendall-test.js +50 -0
- package/esm/data/statistics/maxabs.js +9 -0
- package/esm/data/statistics/pcorrtest.js +76 -0
- package/esm/data/statistics/pettitt-test.js +33 -0
- package/esm/data/statistics/quantile.js +56 -0
- package/esm/data/statistics/types.js +1 -0
- package/esm/data/statistics/vector.js +67 -0
- package/esm/data/statistics/window.js +55 -0
- package/esm/data/types.js +2 -0
- package/esm/data/utils/common.js +58 -0
- package/esm/data/utils/index.js +5 -0
- package/esm/data/utils/isType/constants.js +24 -0
- package/esm/data/utils/isType/index.js +2 -0
- package/esm/data/utils/isType/isDateString.js +104 -0
- package/esm/data/utils/isType/isType.js +78 -0
- package/esm/index.js +11 -0
- package/esm/insight/algorithms/base/compare.js +40 -0
- package/esm/insight/algorithms/categoryOutlier.js +4 -0
- package/esm/insight/algorithms/changePoint.js +10 -0
- package/esm/insight/algorithms/index.js +3 -0
- package/esm/insight/algorithms/trendDirection.js +4 -0
- package/esm/insight/chart/constants.js +25 -0
- package/esm/insight/chart/generator/homogeneous.js +70 -0
- package/esm/insight/chart/generator/index.js +2 -0
- package/esm/insight/chart/generator/insights.js +16 -0
- package/esm/insight/chart/index.js +4 -0
- package/esm/insight/chart/strategy/augmentedMarks/categoryOutlier.js +30 -0
- package/esm/insight/chart/strategy/augmentedMarks/changePoint.js +42 -0
- package/esm/insight/chart/strategy/augmentedMarks/correlation.js +6 -0
- package/esm/insight/chart/strategy/augmentedMarks/homogeneous.js +5 -0
- package/esm/insight/chart/strategy/augmentedMarks/index.js +8 -0
- package/esm/insight/chart/strategy/augmentedMarks/lowVariance.js +23 -0
- package/esm/insight/chart/strategy/augmentedMarks/majority.js +5 -0
- package/esm/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +82 -0
- package/esm/insight/chart/strategy/augmentedMarks/trend.js +26 -0
- package/esm/insight/chart/strategy/chart.js +45 -0
- package/esm/insight/chart/strategy/commonMarks/areaMark.js +12 -0
- package/esm/insight/chart/strategy/commonMarks/index.js +5 -0
- package/esm/insight/chart/strategy/commonMarks/intervalMark.js +14 -0
- package/esm/insight/chart/strategy/commonMarks/lineMark.js +34 -0
- package/esm/insight/chart/strategy/commonMarks/pointMark.js +17 -0
- package/esm/insight/chart/strategy/commonMarks/textMark.js +28 -0
- package/esm/insight/chart/strategy/index.js +4 -0
- package/esm/insight/chart/strategy/viewSpec.js +16 -0
- package/esm/insight/chart/types.js +1 -0
- package/esm/insight/chart/utils.js +4 -0
- package/esm/insight/constant.js +21 -0
- package/esm/insight/index.js +5 -0
- package/esm/insight/insights/checkers.js +97 -0
- package/esm/insight/insights/extractors/categoryOutlier.js +90 -0
- package/esm/insight/insights/extractors/changePoint.js +55 -0
- package/esm/insight/insights/extractors/correlation.js +38 -0
- package/esm/insight/insights/extractors/homogeneous.js +98 -0
- package/esm/insight/insights/extractors/lowVariance.js +49 -0
- package/esm/insight/insights/extractors/majority.js +66 -0
- package/esm/insight/insights/extractors/timeSeriesOutlier.js +61 -0
- package/esm/insight/insights/extractors/trend.js +49 -0
- package/esm/insight/insights/index.js +28 -0
- package/esm/insight/insights/util.js +77 -0
- package/esm/insight/narrative/factory.js +22 -0
- package/esm/insight/narrative/index.js +14 -0
- package/esm/insight/narrative/strategy/base.js +6 -0
- package/esm/insight/narrative/strategy/categoryOutlier.js +74 -0
- package/esm/insight/narrative/strategy/changePoint.js +52 -0
- package/esm/insight/narrative/strategy/commonness.js +45 -0
- package/esm/insight/narrative/strategy/correlation.js +51 -0
- package/esm/insight/narrative/strategy/exception.js +70 -0
- package/esm/insight/narrative/strategy/helpers.js +25 -0
- package/esm/insight/narrative/strategy/index.js +13 -0
- package/esm/insight/narrative/strategy/lowVariance.js +48 -0
- package/esm/insight/narrative/strategy/majority.js +62 -0
- package/esm/insight/narrative/strategy/timeSeriesOutlier.js +92 -0
- package/esm/insight/narrative/strategy/trend.js +57 -0
- package/esm/insight/pipeline/extract.js +236 -0
- package/esm/insight/pipeline/index.js +11 -0
- package/esm/insight/pipeline/insight.js +81 -0
- package/esm/insight/pipeline/preprocess.js +33 -0
- package/esm/insight/pipeline/specificInsight.js +71 -0
- package/esm/insight/pipeline/util.js +14 -0
- package/esm/insight/pipeline/visualize.js +41 -0
- package/esm/insight/types.js +1 -0
- package/esm/insight/utils/aggregate.js +87 -0
- package/esm/insight/utils/common.js +35 -0
- package/esm/ntv/generate/generateTextSpec.js +157 -0
- package/esm/ntv/generate/index.js +5 -0
- package/esm/ntv/generate/types.js +1 -0
- package/esm/ntv/generate/utils.js +86 -0
- package/esm/ntv/index.js +4 -0
- package/esm/ntv/schema/common.js +1 -0
- package/esm/ntv/schema/index.js +4 -0
- package/esm/ntv/schema/paragraph.js +1 -0
- package/esm/ntv/schema/phrase.js +52 -0
- package/esm/ntv/schema/structure.js +1 -0
- package/esm/ntv/types.js +1 -0
- package/esm/ntv/utils/index.js +1 -0
- package/esm/ntv/utils/isSpecType.js +58 -0
- package/esm/utils/arr2map.js +7 -0
- package/esm/utils/dataFormat.js +32 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/isType.js +14 -0
- package/lib/advisor/advise-pipeline/advicesForChart.d.ts +13 -0
- package/lib/advisor/advise-pipeline/advicesForChart.js +73 -0
- package/lib/advisor/advise-pipeline/data-to-advices.d.ts +22 -0
- package/lib/advisor/advise-pipeline/data-to-advices.js +245 -0
- package/lib/advisor/advise-pipeline/index.d.ts +1 -0
- package/lib/advisor/advise-pipeline/index.js +5 -0
- package/lib/advisor/advise-pipeline/spec-mapping.d.ts +14 -0
- package/lib/advisor/advise-pipeline/spec-mapping.js +504 -0
- package/lib/advisor/advisor.d.ts +18 -0
- package/lib/advisor/advisor.js +38 -0
- package/lib/advisor/constants.d.ts +1 -0
- package/lib/advisor/constants.js +16 -0
- package/lib/advisor/index.d.ts +2 -0
- package/lib/advisor/index.js +7 -0
- package/lib/advisor/lint-pipeline/check-rules.d.ts +4 -0
- package/lib/advisor/lint-pipeline/check-rules.js +47 -0
- package/lib/advisor/lint-pipeline/getChartType.d.ts +7 -0
- package/lib/advisor/lint-pipeline/getChartType.js +113 -0
- package/lib/advisor/lint-pipeline/index.d.ts +0 -0
- package/lib/advisor/lint-pipeline/index.js +0 -0
- package/lib/advisor/lint-pipeline/lintRules.d.ts +5 -0
- package/lib/advisor/lint-pipeline/lintRules.js +36 -0
- package/lib/advisor/ruler/index.d.ts +21 -0
- package/lib/advisor/ruler/index.js +80 -0
- package/lib/advisor/ruler/rules/aggregation-single-row.d.ts +2 -0
- package/lib/advisor/ruler/rules/aggregation-single-row.js +24 -0
- package/lib/advisor/ruler/rules/all-can-be-table.d.ts +2 -0
- package/lib/advisor/ruler/rules/all-can-be-table.js +20 -0
- package/lib/advisor/ruler/rules/bar-series-qty.d.ts +2 -0
- package/lib/advisor/ruler/rules/bar-series-qty.js +39 -0
- package/lib/advisor/ruler/rules/bar-without-axis-min.d.ts +2 -0
- package/lib/advisor/ruler/rules/bar-without-axis-min.js +44 -0
- package/lib/advisor/ruler/rules/constants.d.ts +6 -0
- package/lib/advisor/ruler/rules/constants.js +9 -0
- package/lib/advisor/ruler/rules/data-check.d.ts +2 -0
- package/lib/advisor/ruler/rules/data-check.js +43 -0
- package/lib/advisor/ruler/rules/data-field-qty.d.ts +2 -0
- package/lib/advisor/ruler/rules/data-field-qty.js +29 -0
- package/lib/advisor/ruler/rules/diff-pie-sector.d.ts +2 -0
- package/lib/advisor/ruler/rules/diff-pie-sector.js +36 -0
- package/lib/advisor/ruler/rules/index.d.ts +19 -0
- package/lib/advisor/ruler/rules/index.js +71 -0
- package/lib/advisor/ruler/rules/landscape-or-portrait.d.ts +2 -0
- package/lib/advisor/ruler/rules/landscape-or-portrait.js +43 -0
- package/lib/advisor/ruler/rules/limit-series.d.ts +2 -0
- package/lib/advisor/ruler/rules/limit-series.js +50 -0
- package/lib/advisor/ruler/rules/line-field-time-ordinal.d.ts +2 -0
- package/lib/advisor/ruler/rules/line-field-time-ordinal.js +28 -0
- package/lib/advisor/ruler/rules/no-redundant-field.d.ts +2 -0
- package/lib/advisor/ruler/rules/no-redundant-field.js +35 -0
- package/lib/advisor/ruler/rules/nominal-enum-combinatorial.d.ts +2 -0
- package/lib/advisor/ruler/rules/nominal-enum-combinatorial.js +57 -0
- package/lib/advisor/ruler/rules/purpose-check.d.ts +2 -0
- package/lib/advisor/ruler/rules/purpose-check.js +30 -0
- package/lib/advisor/ruler/rules/series-qty-limit.d.ts +2 -0
- package/lib/advisor/ruler/rules/series-qty-limit.js +37 -0
- package/lib/advisor/ruler/rules/x-axis-line-fading.d.ts +2 -0
- package/lib/advisor/ruler/rules/x-axis-line-fading.js +44 -0
- package/lib/advisor/ruler/types.d.ts +125 -0
- package/lib/advisor/ruler/types.js +2 -0
- package/lib/advisor/ruler/utils.d.ts +10 -0
- package/lib/advisor/ruler/utils.js +61 -0
- package/lib/advisor/types.d.ts +218 -0
- package/lib/advisor/types.js +4 -0
- package/lib/advisor/utils/clone.d.ts +2 -0
- package/lib/advisor/utils/clone.js +34 -0
- package/lib/advisor/utils/compare.d.ts +3 -0
- package/lib/advisor/utils/compare.js +17 -0
- package/lib/advisor/utils/computeScore.d.ts +7 -0
- package/lib/advisor/utils/computeScore.js +27 -0
- package/lib/advisor/utils/deep-mix.d.ts +2 -0
- package/lib/advisor/utils/deep-mix.js +78 -0
- package/lib/advisor/utils/hasSubset.d.ts +1 -0
- package/lib/advisor/utils/hasSubset.js +7 -0
- package/lib/advisor/utils/index.d.ts +5 -0
- package/lib/advisor/utils/index.js +19 -0
- package/lib/advisor/utils/inferDataType.d.ts +6 -0
- package/lib/advisor/utils/inferDataType.js +75 -0
- package/lib/advisor/utils/intersects.d.ts +1 -0
- package/lib/advisor/utils/intersects.js +7 -0
- package/lib/advisor/utils/isNil.d.ts +2 -0
- package/lib/advisor/utils/isNil.js +6 -0
- package/lib/ckb/base.d.ts +2 -0
- package/lib/ckb/base.js +1313 -0
- package/lib/ckb/ckb.d.ts +8 -0
- package/lib/ckb/ckb.js +59 -0
- package/lib/ckb/constants.d.ts +79 -0
- package/lib/ckb/constants.js +200 -0
- package/lib/ckb/i18n/index.d.ts +10 -0
- package/lib/ckb/i18n/index.js +27 -0
- package/lib/ckb/i18n/types.d.ts +52 -0
- package/lib/ckb/i18n/types.js +2 -0
- package/lib/ckb/i18n/zh-CN.d.ts +7 -0
- package/lib/ckb/i18n/zh-CN.js +528 -0
- package/lib/ckb/index.d.ts +4 -0
- package/lib/ckb/index.js +20 -0
- package/lib/ckb/types.d.ts +185 -0
- package/lib/ckb/types.js +2 -0
- package/lib/common/types.d.ts +14 -0
- package/lib/common/types.js +2 -0
- package/lib/data/analysis/field/index.d.ts +79 -0
- package/lib/data/analysis/field/index.js +355 -0
- package/lib/data/analysis/field/types.d.ts +99 -0
- package/lib/data/analysis/field/types.js +2 -0
- package/lib/data/analysis/graph/index.d.ts +28 -0
- package/lib/data/analysis/graph/index.js +178 -0
- package/lib/data/analysis/graph/types.d.ts +62 -0
- package/lib/data/analysis/graph/types.js +2 -0
- package/lib/data/analysis/index.d.ts +1 -0
- package/lib/data/analysis/index.js +5 -0
- package/lib/data/analysis/types.d.ts +1 -0
- package/lib/data/analysis/types.js +2 -0
- package/lib/data/dataset/field/baseFrame.d.ts +30 -0
- package/lib/data/dataset/field/baseFrame.js +78 -0
- package/lib/data/dataset/field/dataFrame.d.ts +35 -0
- package/lib/data/dataset/field/dataFrame.js +558 -0
- package/lib/data/dataset/field/index.d.ts +3 -0
- package/lib/data/dataset/field/index.js +8 -0
- package/lib/data/dataset/field/series.d.ts +18 -0
- package/lib/data/dataset/field/series.js +151 -0
- package/lib/data/dataset/field/types.d.ts +54 -0
- package/lib/data/dataset/field/types.js +2 -0
- package/lib/data/dataset/field/utils.d.ts +13 -0
- package/lib/data/dataset/field/utils.js +68 -0
- package/lib/data/dataset/graph/index.d.ts +18 -0
- package/lib/data/dataset/graph/index.js +188 -0
- package/lib/data/dataset/graph/types.d.ts +35 -0
- package/lib/data/dataset/graph/types.js +2 -0
- package/lib/data/dataset/graph/utils.d.ts +1 -0
- package/lib/data/dataset/graph/utils.js +19 -0
- package/lib/data/dataset/index.d.ts +1 -0
- package/lib/data/dataset/index.js +4 -0
- package/lib/data/dataset/types.d.ts +1 -0
- package/lib/data/dataset/types.js +4 -0
- package/lib/data/index.d.ts +5 -0
- package/lib/data/index.js +8 -0
- package/lib/data/statistics/IQR.d.ts +21 -0
- package/lib/data/statistics/IQR.js +53 -0
- package/lib/data/statistics/base.d.ts +106 -0
- package/lib/data/statistics/base.js +271 -0
- package/lib/data/statistics/bayesian.d.ts +5 -0
- package/lib/data/statistics/bayesian.js +30 -0
- package/lib/data/statistics/buishand-u.d.ts +7 -0
- package/lib/data/statistics/buishand-u.js +23 -0
- package/lib/data/statistics/caches.d.ts +13 -0
- package/lib/data/statistics/caches.js +33 -0
- package/lib/data/statistics/cdf.d.ts +7 -0
- package/lib/data/statistics/cdf.js +29 -0
- package/lib/data/statistics/constants.d.ts +5 -0
- package/lib/data/statistics/constants.js +15 -0
- package/lib/data/statistics/index.d.ts +7 -0
- package/lib/data/statistics/index.js +14 -0
- package/lib/data/statistics/lowess.d.ts +10 -0
- package/lib/data/statistics/lowess.js +87 -0
- package/lib/data/statistics/mannkendall-test.d.ts +15 -0
- package/lib/data/statistics/mannkendall-test.js +54 -0
- package/lib/data/statistics/maxabs.d.ts +5 -0
- package/lib/data/statistics/maxabs.js +13 -0
- package/lib/data/statistics/pcorrtest.d.ts +3 -0
- package/lib/data/statistics/pcorrtest.js +80 -0
- package/lib/data/statistics/pettitt-test.d.ts +9 -0
- package/lib/data/statistics/pettitt-test.js +38 -0
- package/lib/data/statistics/quantile.d.ts +16 -0
- package/lib/data/statistics/quantile.js +61 -0
- package/lib/data/statistics/types.d.ts +70 -0
- package/lib/data/statistics/types.js +2 -0
- package/lib/data/statistics/vector.d.ts +15 -0
- package/lib/data/statistics/vector.js +78 -0
- package/lib/data/statistics/window.d.ts +12 -0
- package/lib/data/statistics/window.js +60 -0
- package/lib/data/types.d.ts +2 -0
- package/lib/data/types.js +5 -0
- package/lib/data/utils/common.d.ts +26 -0
- package/lib/data/utils/common.js +67 -0
- package/lib/data/utils/index.d.ts +2 -0
- package/lib/data/utils/index.js +8 -0
- package/lib/data/utils/isType/constants.d.ts +15 -0
- package/lib/data/utils/isType/constants.js +27 -0
- package/lib/data/utils/isType/index.d.ts +2 -0
- package/lib/data/utils/isType/index.js +5 -0
- package/lib/data/utils/isType/isDateString.d.ts +18 -0
- package/lib/data/utils/isType/isDateString.js +111 -0
- package/lib/data/utils/isType/isType.d.ts +13 -0
- package/lib/data/utils/isType/isType.js +94 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +75 -0
- package/lib/insight/algorithms/base/compare.d.ts +14 -0
- package/lib/insight/algorithms/base/compare.js +45 -0
- package/lib/insight/algorithms/categoryOutlier.d.ts +4 -0
- package/lib/insight/algorithms/categoryOutlier.js +7 -0
- package/lib/insight/algorithms/changePoint.d.ts +10 -0
- package/lib/insight/algorithms/changePoint.js +13 -0
- package/lib/insight/algorithms/index.d.ts +3 -0
- package/lib/insight/algorithms/index.js +6 -0
- package/lib/insight/algorithms/trendDirection.d.ts +4 -0
- package/lib/insight/algorithms/trendDirection.js +7 -0
- package/lib/insight/chart/constants.d.ts +13 -0
- package/lib/insight/chart/constants.js +28 -0
- package/lib/insight/chart/generator/homogeneous.d.ts +3 -0
- package/lib/insight/chart/generator/homogeneous.js +75 -0
- package/lib/insight/chart/generator/index.d.ts +2 -0
- package/lib/insight/chart/generator/index.js +5 -0
- package/lib/insight/chart/generator/insights.d.ts +3 -0
- package/lib/insight/chart/generator/insights.js +20 -0
- package/lib/insight/chart/index.d.ts +4 -0
- package/lib/insight/chart/index.js +7 -0
- package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/categoryOutlier.js +35 -0
- package/lib/insight/chart/strategy/augmentedMarks/changePoint.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/changePoint.js +47 -0
- package/lib/insight/chart/strategy/augmentedMarks/correlation.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/correlation.js +10 -0
- package/lib/insight/chart/strategy/augmentedMarks/homogeneous.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/homogeneous.js +9 -0
- package/lib/insight/chart/strategy/augmentedMarks/index.d.ts +8 -0
- package/lib/insight/chart/strategy/augmentedMarks/index.js +24 -0
- package/lib/insight/chart/strategy/augmentedMarks/lowVariance.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/lowVariance.js +28 -0
- package/lib/insight/chart/strategy/augmentedMarks/majority.d.ts +3 -0
- package/lib/insight/chart/strategy/augmentedMarks/majority.js +9 -0
- package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/timeSeriesOutlier.js +87 -0
- package/lib/insight/chart/strategy/augmentedMarks/trend.d.ts +5 -0
- package/lib/insight/chart/strategy/augmentedMarks/trend.js +31 -0
- package/lib/insight/chart/strategy/chart.d.ts +7 -0
- package/lib/insight/chart/strategy/chart.js +49 -0
- package/lib/insight/chart/strategy/commonMarks/areaMark.d.ts +3 -0
- package/lib/insight/chart/strategy/commonMarks/areaMark.js +16 -0
- package/lib/insight/chart/strategy/commonMarks/index.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/index.js +13 -0
- package/lib/insight/chart/strategy/commonMarks/intervalMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/intervalMark.js +18 -0
- package/lib/insight/chart/strategy/commonMarks/lineMark.d.ts +3 -0
- package/lib/insight/chart/strategy/commonMarks/lineMark.js +38 -0
- package/lib/insight/chart/strategy/commonMarks/pointMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/pointMark.js +21 -0
- package/lib/insight/chart/strategy/commonMarks/textMark.d.ts +5 -0
- package/lib/insight/chart/strategy/commonMarks/textMark.js +32 -0
- package/lib/insight/chart/strategy/index.d.ts +4 -0
- package/lib/insight/chart/strategy/index.js +10 -0
- package/lib/insight/chart/strategy/viewSpec.d.ts +3 -0
- package/lib/insight/chart/strategy/viewSpec.js +20 -0
- package/lib/insight/chart/types.d.ts +60 -0
- package/lib/insight/chart/types.js +2 -0
- package/lib/insight/chart/utils.d.ts +3 -0
- package/lib/insight/chart/utils.js +8 -0
- package/lib/insight/constant.d.ts +12 -0
- package/lib/insight/constant.js +24 -0
- package/lib/insight/index.d.ts +6 -0
- package/lib/insight/index.js +13 -0
- package/lib/insight/insights/checkers.d.ts +16 -0
- package/lib/insight/insights/checkers.js +107 -0
- package/lib/insight/insights/extractors/categoryOutlier.d.ts +12 -0
- package/lib/insight/insights/extractors/categoryOutlier.js +95 -0
- package/lib/insight/insights/extractors/changePoint.d.ts +8 -0
- package/lib/insight/insights/extractors/changePoint.js +60 -0
- package/lib/insight/insights/extractors/correlation.d.ts +9 -0
- package/lib/insight/insights/extractors/correlation.js +43 -0
- package/lib/insight/insights/extractors/homogeneous.d.ts +4 -0
- package/lib/insight/insights/extractors/homogeneous.js +103 -0
- package/lib/insight/insights/extractors/lowVariance.d.ts +8 -0
- package/lib/insight/insights/extractors/lowVariance.js +54 -0
- package/lib/insight/insights/extractors/majority.d.ts +10 -0
- package/lib/insight/insights/extractors/majority.js +71 -0
- package/lib/insight/insights/extractors/timeSeriesOutlier.d.ts +2 -0
- package/lib/insight/insights/extractors/timeSeriesOutlier.js +65 -0
- package/lib/insight/insights/extractors/trend.d.ts +9 -0
- package/lib/insight/insights/extractors/trend.js +54 -0
- package/lib/insight/insights/index.d.ts +12 -0
- package/lib/insight/insights/index.js +32 -0
- package/lib/insight/insights/util.d.ts +13 -0
- package/lib/insight/insights/util.js +87 -0
- package/lib/insight/narrative/factory.d.ts +6 -0
- package/lib/insight/narrative/factory.js +25 -0
- package/lib/insight/narrative/index.d.ts +3 -0
- package/lib/insight/narrative/index.js +18 -0
- package/lib/insight/narrative/strategy/base.d.ts +9 -0
- package/lib/insight/narrative/strategy/base.js +9 -0
- package/lib/insight/narrative/strategy/categoryOutlier.d.ts +9 -0
- package/lib/insight/narrative/strategy/categoryOutlier.js +76 -0
- package/lib/insight/narrative/strategy/changePoint.d.ts +8 -0
- package/lib/insight/narrative/strategy/changePoint.js +54 -0
- package/lib/insight/narrative/strategy/commonness.d.ts +9 -0
- package/lib/insight/narrative/strategy/commonness.js +47 -0
- package/lib/insight/narrative/strategy/correlation.d.ts +8 -0
- package/lib/insight/narrative/strategy/correlation.js +53 -0
- package/lib/insight/narrative/strategy/exception.d.ts +10 -0
- package/lib/insight/narrative/strategy/exception.js +72 -0
- package/lib/insight/narrative/strategy/helpers.d.ts +5 -0
- package/lib/insight/narrative/strategy/helpers.js +31 -0
- package/lib/insight/narrative/strategy/index.d.ts +9 -0
- package/lib/insight/narrative/strategy/index.js +28 -0
- package/lib/insight/narrative/strategy/lowVariance.d.ts +8 -0
- package/lib/insight/narrative/strategy/lowVariance.js +50 -0
- package/lib/insight/narrative/strategy/majority.d.ts +8 -0
- package/lib/insight/narrative/strategy/majority.js +64 -0
- package/lib/insight/narrative/strategy/timeSeriesOutlier.d.ts +8 -0
- package/lib/insight/narrative/strategy/timeSeriesOutlier.js +94 -0
- package/lib/insight/narrative/strategy/trend.d.ts +8 -0
- package/lib/insight/narrative/strategy/trend.js +59 -0
- package/lib/insight/pipeline/extract.d.ts +13 -0
- package/lib/insight/pipeline/extract.js +243 -0
- package/lib/insight/pipeline/index.d.ts +2 -0
- package/lib/insight/pipeline/index.js +15 -0
- package/lib/insight/pipeline/insight.d.ts +10 -0
- package/lib/insight/pipeline/insight.js +86 -0
- package/lib/insight/pipeline/preprocess.d.ts +6 -0
- package/lib/insight/pipeline/preprocess.js +39 -0
- package/lib/insight/pipeline/specificInsight.d.ts +11 -0
- package/lib/insight/pipeline/specificInsight.js +79 -0
- package/lib/insight/pipeline/util.d.ts +5 -0
- package/lib/insight/pipeline/util.js +20 -0
- package/lib/insight/pipeline/visualize.d.ts +3 -0
- package/lib/insight/pipeline/visualize.js +46 -0
- package/lib/insight/types.d.ts +238 -0
- package/lib/insight/types.js +2 -0
- package/lib/insight/utils/aggregate.d.ts +7 -0
- package/lib/insight/utils/aggregate.js +93 -0
- package/lib/insight/utils/common.d.ts +3 -0
- package/lib/insight/utils/common.js +41 -0
- package/lib/ntv/generate/generateTextSpec.d.ts +9 -0
- package/lib/ntv/generate/generateTextSpec.js +160 -0
- package/lib/ntv/generate/index.d.ts +2 -0
- package/lib/ntv/generate/index.js +12 -0
- package/lib/ntv/generate/types.d.ts +58 -0
- package/lib/ntv/generate/types.js +2 -0
- package/lib/ntv/generate/utils.d.ts +29 -0
- package/lib/ntv/generate/utils.js +96 -0
- package/lib/ntv/index.d.ts +4 -0
- package/lib/ntv/index.js +10 -0
- package/lib/ntv/schema/common.d.ts +17 -0
- package/lib/ntv/schema/common.js +2 -0
- package/lib/ntv/schema/index.d.ts +4 -0
- package/lib/ntv/schema/index.js +7 -0
- package/lib/ntv/schema/paragraph.d.ts +34 -0
- package/lib/ntv/schema/paragraph.js +2 -0
- package/lib/ntv/schema/phrase.d.ts +70 -0
- package/lib/ntv/schema/phrase.js +55 -0
- package/lib/ntv/schema/structure.d.ts +18 -0
- package/lib/ntv/schema/structure.js +2 -0
- package/lib/ntv/types.d.ts +2 -0
- package/lib/ntv/types.js +2 -0
- package/lib/ntv/utils/index.d.ts +1 -0
- package/lib/ntv/utils/index.js +4 -0
- package/lib/ntv/utils/isSpecType.d.ts +17 -0
- package/lib/ntv/utils/isSpecType.js +76 -0
- package/lib/utils/arr2map.d.ts +1 -0
- package/lib/utils/arr2map.js +11 -0
- package/lib/utils/dataFormat.d.ts +11 -0
- package/lib/utils/dataFormat.js +35 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +8 -0
- package/lib/utils/isType.d.ts +4 -0
- package/lib/utils/isType.js +21 -0
- package/package.json +88 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { LevelOfMeasurement } from '../../../ckb';
|
|
2
|
+
/**
|
|
3
|
+
* Field Type
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type FieldType = 'null' | 'boolean' | 'integer' | 'float' | 'date' | 'string';
|
|
7
|
+
/**
|
|
8
|
+
* The field meta which be existed only the Field type is mixed
|
|
9
|
+
*/
|
|
10
|
+
export type FieldMeta = {
|
|
11
|
+
integer?: NumberFieldInfo;
|
|
12
|
+
float?: NumberFieldInfo;
|
|
13
|
+
date?: DateFieldInfo;
|
|
14
|
+
string?: StringFieldInfo;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Basic info of field
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export type FieldInfo = {
|
|
21
|
+
/** field name */
|
|
22
|
+
name?: string;
|
|
23
|
+
/** field type */
|
|
24
|
+
type: FieldType | 'mixed';
|
|
25
|
+
/** recommendation type */
|
|
26
|
+
recommendation: FieldType;
|
|
27
|
+
/** number of empty includes null undefined or empty string */
|
|
28
|
+
missing?: number;
|
|
29
|
+
/** distinct count */
|
|
30
|
+
distinct?: number;
|
|
31
|
+
/** Number of each distinct item */
|
|
32
|
+
valueMap?: Record<string, number>;
|
|
33
|
+
/** count of rawData */
|
|
34
|
+
count?: number;
|
|
35
|
+
/** rawData */
|
|
36
|
+
rawData: any[];
|
|
37
|
+
/** more info */
|
|
38
|
+
meta?: FieldMeta;
|
|
39
|
+
/** level of measurements */
|
|
40
|
+
levelOfMeasurements?: LevelOfMeasurement[];
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* String Field
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
export type StringFieldInfo = FieldInfo & {
|
|
47
|
+
/** max length */
|
|
48
|
+
maxLength: number;
|
|
49
|
+
/** min length */
|
|
50
|
+
minLength: number;
|
|
51
|
+
/** mean of length */
|
|
52
|
+
meanLength: number;
|
|
53
|
+
/** is contain charts */
|
|
54
|
+
containsChar: boolean;
|
|
55
|
+
/** is contain digits */
|
|
56
|
+
containsDigit: boolean;
|
|
57
|
+
/** is contain white space */
|
|
58
|
+
containsSpace: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Number Field
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export type NumberFieldInfo = FieldInfo & {
|
|
65
|
+
/** the counts of zero value */
|
|
66
|
+
zeros: number;
|
|
67
|
+
/** minimum */
|
|
68
|
+
minimum: number;
|
|
69
|
+
/** 5% percentile */
|
|
70
|
+
percentile5: number;
|
|
71
|
+
/** 25% percentile */
|
|
72
|
+
percentile25: number;
|
|
73
|
+
/** 50% percentile */
|
|
74
|
+
percentile50: number;
|
|
75
|
+
/** 75% percentile */
|
|
76
|
+
percentile75: number;
|
|
77
|
+
/** 95% percentile */
|
|
78
|
+
percentile95: number;
|
|
79
|
+
/** maximum */
|
|
80
|
+
maximum: number;
|
|
81
|
+
/** standardDeviation */
|
|
82
|
+
standardDeviation: number;
|
|
83
|
+
/** mean */
|
|
84
|
+
mean: number;
|
|
85
|
+
/** sum */
|
|
86
|
+
sum: number;
|
|
87
|
+
/** variance */
|
|
88
|
+
variance: number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Date Field
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export interface DateFieldInfo extends FieldInfo {
|
|
95
|
+
/** minimum date */
|
|
96
|
+
minimum: string | number | Date;
|
|
97
|
+
/** maximum date */
|
|
98
|
+
maximum: string | number | Date;
|
|
99
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { NodeData, LinkData } from '../../dataset/graph/types';
|
|
2
|
+
import type { FieldInfo } from '../field/types';
|
|
3
|
+
import type { GraphFeat } from './types';
|
|
4
|
+
export declare function getNodeFields(nodes: NodeData[]): {
|
|
5
|
+
nodeFields: any[];
|
|
6
|
+
nodeFieldNames: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare function getLinkFields(links: LinkData[]): {
|
|
9
|
+
linkFields: any[];
|
|
10
|
+
linkFieldNames: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare function getAllFieldsInfo(dataFields: any[], fieldNames: string[]): FieldInfo[];
|
|
13
|
+
/**
|
|
14
|
+
* find node clusters and assign the cluster field to each node
|
|
15
|
+
* @param nodes
|
|
16
|
+
* @param links
|
|
17
|
+
*/
|
|
18
|
+
export declare function clusterNodes(nodes: NodeData[], nodeFieldsInfo: FieldInfo[], links: LinkData[]): FieldInfo;
|
|
19
|
+
/**
|
|
20
|
+
* Calculate statistical and structural features for graph
|
|
21
|
+
* @param nodes
|
|
22
|
+
* @param links
|
|
23
|
+
*/
|
|
24
|
+
export declare function getAllStructFeats(nodes: NodeData[], links: LinkData[]): {
|
|
25
|
+
nodeFeats: FieldInfo[];
|
|
26
|
+
linkFeats: FieldInfo[];
|
|
27
|
+
graphInfo: Partial<GraphFeat>;
|
|
28
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllStructFeats = exports.clusterNodes = exports.getAllFieldsInfo = exports.getLinkFields = exports.getNodeFields = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
// TODO @chenluli: move @antv/algorithm from devDep to dep after this file is complete
|
|
6
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
7
|
+
var AlgorithmSync = tslib_1.__importStar(require("@antv/algorithm"));
|
|
8
|
+
var field_1 = require("../field");
|
|
9
|
+
var GraphAlgorithms = tslib_1.__assign({}, AlgorithmSync);
|
|
10
|
+
function generateColDataFromArray(arr, columnNames) {
|
|
11
|
+
var fields = [];
|
|
12
|
+
for (var i = 0; i < arr.length; i += 1) {
|
|
13
|
+
var datum = arr[i];
|
|
14
|
+
for (var j = 0; j < columnNames.length; j += 1) {
|
|
15
|
+
var column = columnNames[j];
|
|
16
|
+
if (fields[j]) {
|
|
17
|
+
fields[j].push(datum[column]);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
fields[j] = [datum[column]];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return fields;
|
|
25
|
+
}
|
|
26
|
+
function getNodeFields(nodes) {
|
|
27
|
+
var _a = tslib_1.__read(nodes, 1), node0 = _a[0];
|
|
28
|
+
var nodeFieldNames = node0 ? Object.keys(node0) : [];
|
|
29
|
+
var nodeFields = generateColDataFromArray(nodes, nodeFieldNames);
|
|
30
|
+
return { nodeFields: nodeFields, nodeFieldNames: nodeFieldNames };
|
|
31
|
+
}
|
|
32
|
+
exports.getNodeFields = getNodeFields;
|
|
33
|
+
function getLinkFields(links) {
|
|
34
|
+
var _a = tslib_1.__read(links, 1), link0 = _a[0];
|
|
35
|
+
var linkFieldNames = link0 ? Object.keys(link0) : [];
|
|
36
|
+
var linkFields = generateColDataFromArray(links, linkFieldNames);
|
|
37
|
+
return { linkFields: linkFields, linkFieldNames: linkFieldNames };
|
|
38
|
+
}
|
|
39
|
+
exports.getLinkFields = getLinkFields;
|
|
40
|
+
// Analyze fields
|
|
41
|
+
function getFieldInfo(dataField, fieldName) {
|
|
42
|
+
var fieldInfo = (0, field_1.analyzeField)(dataField);
|
|
43
|
+
return tslib_1.__assign(tslib_1.__assign({}, fieldInfo), { name: fieldName });
|
|
44
|
+
}
|
|
45
|
+
function getAllFieldsInfo(dataFields, fieldNames) {
|
|
46
|
+
var fields = [];
|
|
47
|
+
for (var i = 0; i < dataFields.length; i += 1) {
|
|
48
|
+
var dataField = dataFields[i];
|
|
49
|
+
fields.push(getFieldInfo(dataField, fieldNames[i]));
|
|
50
|
+
}
|
|
51
|
+
return fields;
|
|
52
|
+
}
|
|
53
|
+
exports.getAllFieldsInfo = getAllFieldsInfo;
|
|
54
|
+
/* eslint-disable no-param-reassign */
|
|
55
|
+
/**
|
|
56
|
+
* find node clusters and assign the cluster field to each node
|
|
57
|
+
* @param nodes
|
|
58
|
+
* @param links
|
|
59
|
+
*/
|
|
60
|
+
function clusterNodes(nodes, nodeFieldsInfo, links) {
|
|
61
|
+
var MAX_CLUSTER_NUM = 10;
|
|
62
|
+
var fieldForCluster;
|
|
63
|
+
for (var i = 0; i < nodeFieldsInfo.length; i += 1) {
|
|
64
|
+
var field = nodeFieldsInfo[i];
|
|
65
|
+
if (field.levelOfMeasurements.indexOf('Nominal') > -1 ||
|
|
66
|
+
(field.levelOfMeasurements.indexOf('Ordinal') > -1 &&
|
|
67
|
+
field.missing === 0 &&
|
|
68
|
+
field.distinct > 1 &&
|
|
69
|
+
field.distinct <= MAX_CLUSTER_NUM)) {
|
|
70
|
+
fieldForCluster = field;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (fieldForCluster) {
|
|
75
|
+
for (var nodeIdx = 0; nodeIdx < nodes.length; nodeIdx += 1) {
|
|
76
|
+
nodes[nodeIdx].cluster = nodes[nodeIdx][fieldForCluster.name];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
var clusters = GraphAlgorithms.louvain({ nodes: nodes, edges: links }).clusters;
|
|
81
|
+
var values = [];
|
|
82
|
+
for (var i = 0; i < clusters.length; i += 1) {
|
|
83
|
+
var cluster = clusters[i];
|
|
84
|
+
var nodes_1 = cluster.nodes, id = cluster.id;
|
|
85
|
+
for (var nodeIdx = 0; nodeIdx < nodes_1.length; nodeIdx += 1) {
|
|
86
|
+
nodes_1[nodeIdx].cluster = id;
|
|
87
|
+
}
|
|
88
|
+
values.push(id);
|
|
89
|
+
}
|
|
90
|
+
fieldForCluster = tslib_1.__assign(tslib_1.__assign({}, (0, field_1.analyzeField)(values)), { name: 'cluster' });
|
|
91
|
+
}
|
|
92
|
+
return fieldForCluster;
|
|
93
|
+
}
|
|
94
|
+
exports.clusterNodes = clusterNodes;
|
|
95
|
+
/* eslint-disable no-param-reassign */
|
|
96
|
+
/**
|
|
97
|
+
* Calculate statistical and structural features for graph
|
|
98
|
+
* @param nodes
|
|
99
|
+
* @param links
|
|
100
|
+
*/
|
|
101
|
+
function getAllStructFeats(nodes, links) {
|
|
102
|
+
var nodeStructFeats = [];
|
|
103
|
+
var linkStructFeats = [];
|
|
104
|
+
// TODO: whether the graph is directed need to be passed in
|
|
105
|
+
var isDirected = false;
|
|
106
|
+
var degrees = GraphAlgorithms.getDegree({ nodes: nodes, edges: links });
|
|
107
|
+
var pageRanks = GraphAlgorithms.pageRank({ nodes: nodes, edges: links });
|
|
108
|
+
var cycles = GraphAlgorithms.detectAllCycles({ nodes: nodes, edges: links }, false);
|
|
109
|
+
var directedCycles = GraphAlgorithms.detectAllDirectedCycle({ nodes: nodes, edges: links });
|
|
110
|
+
var components = GraphAlgorithms.connectedComponent({ nodes: nodes, edges: links }, false);
|
|
111
|
+
var strongConnectedComponents = GraphAlgorithms.connectedComponent({ nodes: nodes, edges: links }, true);
|
|
112
|
+
var cycleCountMap = {};
|
|
113
|
+
for (var i = 0; i < cycles.length; i += 1) {
|
|
114
|
+
var nodeIds = Object.keys(cycles[i]);
|
|
115
|
+
for (var j = 0; j < nodeIds.length; j += 1) {
|
|
116
|
+
var nodeId = nodeIds[j];
|
|
117
|
+
if (cycleCountMap[nodeId]) {
|
|
118
|
+
cycleCountMap[nodeId] += 1;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
cycleCountMap[nodeId] = 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
var numberOfNodeInCycle = Object.values(cycleCountMap).filter(function (count) { return count; }).length;
|
|
126
|
+
var cycleParticipate = numberOfNodeInCycle / nodes.length;
|
|
127
|
+
for (var index = 0; index < nodes.length; index += 1) {
|
|
128
|
+
var node = nodes[index];
|
|
129
|
+
var nodeFeat = {
|
|
130
|
+
degree: degrees[node.id].degree,
|
|
131
|
+
inDegree: degrees[node.id].inDegree,
|
|
132
|
+
outDegree: degrees[node.id].outDegree,
|
|
133
|
+
pageRank: pageRanks[node.id],
|
|
134
|
+
cycleCount: cycleCountMap[node.id] || 0,
|
|
135
|
+
};
|
|
136
|
+
nodeStructFeats.push(nodeFeat);
|
|
137
|
+
nodes[index] = tslib_1.__assign(tslib_1.__assign({}, node), nodeFeat);
|
|
138
|
+
}
|
|
139
|
+
for (var index = 0; index < links.length; index += 1) {
|
|
140
|
+
var link = links[index];
|
|
141
|
+
var linkFeat = {};
|
|
142
|
+
linkStructFeats.push(linkFeat);
|
|
143
|
+
links[index] = tslib_1.__assign(tslib_1.__assign({}, link), linkFeat);
|
|
144
|
+
}
|
|
145
|
+
var nodeFeatNames = Object.keys(nodeStructFeats[0]);
|
|
146
|
+
var linkFeatNames = Object.keys(linkStructFeats[0]);
|
|
147
|
+
var nodeFeats = getAllFieldsInfo(generateColDataFromArray(nodeStructFeats, nodeFeatNames), nodeFeatNames);
|
|
148
|
+
var linkFeats = getAllFieldsInfo(generateColDataFromArray(linkStructFeats, linkFeatNames), linkFeatNames);
|
|
149
|
+
// Calculate the structural features and statistics of all nodes and links
|
|
150
|
+
var nodeDegrees = nodes.map(function (node) { return Number(node.degree); });
|
|
151
|
+
var avgDegree = nodeDegrees.reduce(function (x, y) { return x + y; }) / nodeDegrees.length;
|
|
152
|
+
var degreeDev = nodeDegrees.map(function (x) { return x - avgDegree; });
|
|
153
|
+
var degreeStd = Math.sqrt(degreeDev.map(function (x) { return Math.pow(x, 2); }).reduce(function (x, y) { return x + y; }) / (nodeDegrees.length - 1));
|
|
154
|
+
var graphInfo = {
|
|
155
|
+
isDirected: isDirected,
|
|
156
|
+
nodeCount: nodes.length,
|
|
157
|
+
linkCount: links.length,
|
|
158
|
+
isConnected: components && components.length === 1,
|
|
159
|
+
isDAG: isDirected && directedCycles.length === 0,
|
|
160
|
+
maxDegree: Math.max.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(nodeDegrees), false)),
|
|
161
|
+
avgDegree: avgDegree,
|
|
162
|
+
degreeStd: degreeStd,
|
|
163
|
+
cycleParticipate: cycleParticipate,
|
|
164
|
+
cycleCount: cycles.length,
|
|
165
|
+
directedCycleCount: directedCycles.length,
|
|
166
|
+
// triangleCount: triangleMatches.length,
|
|
167
|
+
componentCount: components.length,
|
|
168
|
+
components: components,
|
|
169
|
+
strongConnectedComponents: strongConnectedComponents,
|
|
170
|
+
strongConnectedComponentCount: strongConnectedComponents.length,
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
nodeFeats: nodeFeats,
|
|
174
|
+
linkFeats: linkFeats,
|
|
175
|
+
graphInfo: graphInfo,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
exports.getAllStructFeats = getAllStructFeats;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { FieldInfo } from '../field/types';
|
|
2
|
+
export type NodeStructFeat = {
|
|
3
|
+
degree: number;
|
|
4
|
+
inDegree: number;
|
|
5
|
+
outDegree: number;
|
|
6
|
+
pageRank: number;
|
|
7
|
+
closeness: number;
|
|
8
|
+
kCore: number;
|
|
9
|
+
cycleCount: number;
|
|
10
|
+
triangleCount: number;
|
|
11
|
+
starCount: number;
|
|
12
|
+
cliqueCount: number;
|
|
13
|
+
clusterCoeff: number;
|
|
14
|
+
};
|
|
15
|
+
export type LinkStructFeat = {
|
|
16
|
+
isDirected: Boolean;
|
|
17
|
+
centrality: number;
|
|
18
|
+
cycleCount: number;
|
|
19
|
+
triangleCount: number;
|
|
20
|
+
starCount: number;
|
|
21
|
+
cliqueCount: number;
|
|
22
|
+
};
|
|
23
|
+
export type GraphFeat = {
|
|
24
|
+
nodeCount: number;
|
|
25
|
+
linkCount: number;
|
|
26
|
+
direction: number;
|
|
27
|
+
isDirected: Boolean;
|
|
28
|
+
isDAG: Boolean;
|
|
29
|
+
isCycle: Boolean;
|
|
30
|
+
isConnected: Boolean;
|
|
31
|
+
ratio: number;
|
|
32
|
+
breadth: number;
|
|
33
|
+
depth: number;
|
|
34
|
+
maxDegree: number;
|
|
35
|
+
minDegree: number;
|
|
36
|
+
avgDegree: number;
|
|
37
|
+
degreeStd: number;
|
|
38
|
+
maxPageRank: number;
|
|
39
|
+
minPageRank: number;
|
|
40
|
+
avgPageRank: number;
|
|
41
|
+
components: any[];
|
|
42
|
+
componentCount: number;
|
|
43
|
+
strongConnectedComponents: any[];
|
|
44
|
+
strongConnectedComponentCount: number;
|
|
45
|
+
cycleCount: number;
|
|
46
|
+
directedCycleCount: number;
|
|
47
|
+
starCount: number;
|
|
48
|
+
cliqueCount: number;
|
|
49
|
+
cycleParticipate: number;
|
|
50
|
+
triangleCount: number;
|
|
51
|
+
localClusterCoeff: number;
|
|
52
|
+
globalClusterCoeff: number;
|
|
53
|
+
maxKCore: number;
|
|
54
|
+
};
|
|
55
|
+
export type GraphProps = {
|
|
56
|
+
nodeFeats: FieldInfo[];
|
|
57
|
+
linkFeats: FieldInfo[];
|
|
58
|
+
graphInfo: Partial<GraphFeat>;
|
|
59
|
+
nodeFieldsInfo: FieldInfo[];
|
|
60
|
+
linkFieldsInfo: FieldInfo[];
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { analyzeField } from './field';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { FieldType, FieldInfo, StringFieldInfo, NumberFieldInfo, DateFieldInfo } from './field/types';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { NDArray, SeriesData, FrameData, Axis, Extra } from './types';
|
|
2
|
+
export default abstract class BaseFrame {
|
|
3
|
+
axes: [Axis[]] | [Axis[], Axis[]];
|
|
4
|
+
data: NDArray;
|
|
5
|
+
colData?: NDArray;
|
|
6
|
+
extra?: Extra;
|
|
7
|
+
constructor(data: SeriesData | FrameData, extra?: Extra);
|
|
8
|
+
abstract get shape(): [number] | [number, number];
|
|
9
|
+
get indexes(): Axis[];
|
|
10
|
+
get columns(): Axis[];
|
|
11
|
+
private getAxis;
|
|
12
|
+
/**
|
|
13
|
+
* Set axis. Only the 0 and 1 are currently supported.
|
|
14
|
+
* @param axis
|
|
15
|
+
* @param labels
|
|
16
|
+
*/
|
|
17
|
+
setAxis(axis: number, values: Axis[]): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get data by row location and column location.
|
|
20
|
+
* @param rowLoc
|
|
21
|
+
* @param colLoc
|
|
22
|
+
*/
|
|
23
|
+
abstract get(rowLoc: Axis | Axis[] | string, colLoc?: Axis | Axis[] | string): BaseFrame;
|
|
24
|
+
/**
|
|
25
|
+
* Get data by row location and column location using integer index.
|
|
26
|
+
* @param rowLoc
|
|
27
|
+
* @param colLoc
|
|
28
|
+
*/
|
|
29
|
+
abstract getByIndex(rowLoc: number | number[] | string, colLoc?: number | number[] | string): BaseFrame;
|
|
30
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var utils_1 = require("../../utils");
|
|
4
|
+
var utils_2 = require("./utils");
|
|
5
|
+
/* Base data structure */
|
|
6
|
+
var BaseFrame = /** @class */ (function () {
|
|
7
|
+
function BaseFrame(data, extra) {
|
|
8
|
+
var _a, _b, _c, _d, _e;
|
|
9
|
+
this.axes = [[]];
|
|
10
|
+
this.data = [];
|
|
11
|
+
(0, utils_1.assert)(!extra || (0, utils_1.isObject)(extra), 'If extra exists, it must be an object.');
|
|
12
|
+
/* 1D: basic type */
|
|
13
|
+
if ((0, utils_1.isBasicType)(data)) {
|
|
14
|
+
// generate indexes
|
|
15
|
+
if (extra === null || extra === void 0 ? void 0 : extra.indexes) {
|
|
16
|
+
this.setAxis(0, extra === null || extra === void 0 ? void 0 : extra.indexes);
|
|
17
|
+
this.data = Array(extra === null || extra === void 0 ? void 0 : extra.indexes.length).fill((0, utils_2.convertDataType)((0, utils_2.fillMissingValue)(data, extra === null || extra === void 0 ? void 0 : extra.fillValue), (_a = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _a === void 0 ? void 0 : _a[0]));
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.data = [(0, utils_2.convertDataType)((0, utils_2.fillMissingValue)(data, extra === null || extra === void 0 ? void 0 : extra.fillValue), (_b = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _b === void 0 ? void 0 : _b[0])];
|
|
21
|
+
this.setAxis(0, [0]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if ((0, utils_1.isArray)(data)) {
|
|
25
|
+
/* 1D: array */
|
|
26
|
+
var legal = true;
|
|
27
|
+
for (var i = 0; i < data.length; i += 1) {
|
|
28
|
+
var datum = data[i];
|
|
29
|
+
// For DataFrame, as long as any datum in data is basic type, it's a 1D array
|
|
30
|
+
if (!(0, utils_1.isBasicType)(datum)) {
|
|
31
|
+
legal = false;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
this.setAxis(0, (0, utils_2.generateArrayIndex)(data, extra === null || extra === void 0 ? void 0 : extra.indexes));
|
|
36
|
+
if (legal) {
|
|
37
|
+
if (extra === null || extra === void 0 ? void 0 : extra.indexes) {
|
|
38
|
+
(0, utils_1.assert)(((_c = extra === null || extra === void 0 ? void 0 : extra.indexes) === null || _c === void 0 ? void 0 : _c.length) === data.length, "Index length is ".concat(extra === null || extra === void 0 ? void 0 : extra.indexes.length, ", but data size ").concat(data.length));
|
|
39
|
+
this.setAxis(0, extra === null || extra === void 0 ? void 0 : extra.indexes);
|
|
40
|
+
}
|
|
41
|
+
this.data = (extra === null || extra === void 0 ? void 0 : extra.fillValue) ? data.map(function (datum) { return (0, utils_2.fillMissingValue)(datum, extra === null || extra === void 0 ? void 0 : extra.fillValue); }) : data;
|
|
42
|
+
if ((_d = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _d === void 0 ? void 0 : _d.length) {
|
|
43
|
+
for (var i = 0; i < this.data.length; i += 1) {
|
|
44
|
+
this.data[i] = (0, utils_2.convertDataType)(this.data[i], (_e = extra === null || extra === void 0 ? void 0 : extra.columnTypes) === null || _e === void 0 ? void 0 : _e[0]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
Object.defineProperty(BaseFrame.prototype, "indexes", {
|
|
51
|
+
get: function () {
|
|
52
|
+
return this.getAxis(0);
|
|
53
|
+
},
|
|
54
|
+
enumerable: false,
|
|
55
|
+
configurable: true
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(BaseFrame.prototype, "columns", {
|
|
58
|
+
get: function () {
|
|
59
|
+
return this.getAxis(1);
|
|
60
|
+
},
|
|
61
|
+
enumerable: false,
|
|
62
|
+
configurable: true
|
|
63
|
+
});
|
|
64
|
+
BaseFrame.prototype.getAxis = function (axis) {
|
|
65
|
+
return this.axes[axis];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Set axis. Only the 0 and 1 are currently supported.
|
|
69
|
+
* @param axis
|
|
70
|
+
* @param labels
|
|
71
|
+
*/
|
|
72
|
+
BaseFrame.prototype.setAxis = function (axis, values) {
|
|
73
|
+
(0, utils_1.assert)((0, utils_1.isArray)(values), 'Index or columns must be Axis array.');
|
|
74
|
+
this.axes[axis] = values;
|
|
75
|
+
};
|
|
76
|
+
return BaseFrame;
|
|
77
|
+
}());
|
|
78
|
+
exports.default = BaseFrame;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import BaseFrame from './baseFrame';
|
|
2
|
+
import Series from './series';
|
|
3
|
+
import type { FrameData, Axis, Extra, FieldsInfo } from './types';
|
|
4
|
+
export default class DataFrame extends BaseFrame {
|
|
5
|
+
constructor(data: FrameData, extra?: Extra);
|
|
6
|
+
/**
|
|
7
|
+
* Generate columns.
|
|
8
|
+
* @param columns
|
|
9
|
+
* @param extra
|
|
10
|
+
*/
|
|
11
|
+
private generateColumns;
|
|
12
|
+
/**
|
|
13
|
+
* Generate this.data and this.colData.
|
|
14
|
+
* @param isObj
|
|
15
|
+
* @param data
|
|
16
|
+
* @param columns
|
|
17
|
+
*/
|
|
18
|
+
private generateDataAndColDataFromArray;
|
|
19
|
+
get shape(): [number, number];
|
|
20
|
+
get(rowLoc: Axis | Axis[] | string, colLoc?: Axis | Axis[] | string): DataFrame | Series | any;
|
|
21
|
+
getByIndex(rowLoc: number | number[] | string, colLoc?: number | number[] | string): DataFrame | Series | any;
|
|
22
|
+
/**
|
|
23
|
+
* Get data by column.
|
|
24
|
+
* @param col
|
|
25
|
+
*/
|
|
26
|
+
getByColumn(col: Axis): Series;
|
|
27
|
+
/**
|
|
28
|
+
* Get statistics.
|
|
29
|
+
*/
|
|
30
|
+
info(): FieldsInfo;
|
|
31
|
+
/**
|
|
32
|
+
* Get tabular data string.
|
|
33
|
+
*/
|
|
34
|
+
toString(): string;
|
|
35
|
+
}
|