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AAO,SAAU,EAAU,GAC3C,IAAI,EAAU,KAAK,IAAI,EAAK,SAAS,KAAK,UAAU,IAAQ,GAExD,EAAgB,EAAO,MAAM,GACjC,EAAc,KAAK,GAEnB,EAAS,KAAK,EAAM,oBAAoB,EAAe,IAGvD,IAAI,EAAY,EAAK,qBAAqB,GAE1C,OAAI,EACO,EAAS,OAAO,EAAM,UAAU,EAAW,EAAS,IACxD,CACX,GAAG,GACP,EAQA,EAAS,UAAU,kBAAoB,SAAU,EAAY,GAEzD,MAAO,EACX,EAQA,EAAS,UAAU,oBAAsB,SAAU,EAAS,GACxD,IAAI,EAAM,CACN,MAAO,EACP,QAAS,GAGb,OADA,KAAK,KAAK,OAAQ,GACX,CACX,EAOA,EAAS,UAAU,uBAAyB,SAAU,GAClD,OAAO,EAAa,QAAO,SAAU,EAAO,GACxC,OAAO,EAAI,QAAO,SAAU,EAAO,GAE/B,OADA,EAAM,KAAK,UAAU,KAAU,EAAM,KAAK,UAAU,KAAU,GAAK,EAC5D,CACX,GAAG,EACP,GAAG,CAAC,EACR,EACO,CACX,CAxH6B,CAwH3B,SAAS,cACX,QAAQ,SAAW","file":"/npm/node-fpgrowth@1.2.1/dist/fpgrowth.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/node-fpgrowth@1.2.1/dist/fpgrowth.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __extends = (this && this.__extends) || (function () {\n    var extendStatics = Object.setPrototypeOf ||\n        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n    return function (d, b) {\n        extendStatics(d, b);\n        function __() { this.constructor = d; }\n        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n    };\n})();\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar events_1 = require(\"events\");\nvar fptree_1 = require(\"./fptree\");\nvar FPGrowth = /** @class */ (function (_super) {\n    __extends(FPGrowth, _super);\n    /**\n     * FPGrowth is an algorithm for frequent item set mining and association rule\n     * earning over transactional databases.\n     * It was proposed by Han et al. (2000). FPGrowth is a very fast and memory efficient algorithm. It uses a special internal structure called an FP-Tree.\n     *\n     * @param  {number} _support 0 < _support < 1. Minimum support of itemsets to mine.\n     */\n    function FPGrowth(_support /*, private _confidence: number*/) {\n        var _this = _super.call(this) || this;\n        _this._support = _support;\n        /**\n         * Output of the algorithm: The mined frequent itemsets.\n         */\n        _this._itemsets = [];\n        return _this;\n    }\n    /**\n     * Executes the FPGrowth Algorithm.\n     * You can keep track of frequent itemsets as they are mined by listening to the 'data' event on the FPGrowth object.\n     * All mined itemsets, as well as basic execution stats, are returned at the end of the execution through a callback function or a Promise.\n     *\n     * @param  {T[][]}              transactions The transactions from which you want to mine itemsets.\n     * @param  {IAprioriResults<T>} cb           Callback function returning the results.\n     * @return {Promise<IAprioriResults<T>>}     Promise returning the results.\n     */\n    FPGrowth.prototype.exec = function (transactions, cb) {\n        var _this = this;\n        this._transactions = transactions;\n        // Relative support.\n        this._support = Math.ceil(this._support * transactions.length);\n        // First scan to determine the occurence of each unique item.\n        var supports = this._getDistinctItemsCount(this._transactions);\n        return new Promise(function (resolve, reject) {\n            // Building the FP-Tree...\n            var tree = new fptree_1.FPTree(supports, _this._support).fromTransactions(_this._transactions);\n            // Running the algorithm on the main tree.\n            // All the frequent itemsets are returned at the end of the execution.\n            var result = _this._fpGrowth(tree, _this._transactions.length);\n            if (cb)\n                cb(result);\n            resolve(result);\n        });\n    };\n    /**\n     * RECURSIVE CALL - Returns mined itemset from each conditional sub-FPTree of the given FPtree.\n     *\n     * @param  {FPTree<T>}  tree          The FPTree you want to mine.\n     * @param  {number}     prefixSupport The support of the FPTree's current prefix.\n     * @param  {T[]}        prefix        The current prefix associated with the FPTree.\n     * @return {Itemset<T>}               The mined itemsets.\n     */\n    FPGrowth.prototype._fpGrowth = function (tree, prefixSupport, prefix) {\n        // Test whether or not the FP-Tree is single path.\n        // If it is, we can short-cut the mining process pretty efficiently.\n        // TODO: let singlePath: FPNode<T>[] = tree.getSinglePath();\n        // TODO: if(singlePath) return this._handleSinglePath(singlePath, prefix);\n        var _this = this;\n        if (prefix === void 0) { prefix = []; }\n        // For each header, ordered ascendingly by their support, determining the prefix paths.\n        // These prefix paths represent new transactions to mine in a new FPTree.\n        // If no prefix path can be mined, the algorithm stops.\n        return tree.headers.reduce(function (itemsets, item) {\n            var support = Math.min(tree.supports[JSON.stringify(item)], prefixSupport);\n            // Array copy.\n            var currentPrefix = prefix.slice(0);\n            currentPrefix.push(item);\n            // Prefix is a mined itemset.\n            itemsets.push(_this._getFrequentItemset(currentPrefix, support));\n            // Method below generates the prefix paths of the current item, as well as the support of\n            // each item composing the prefix paths, and returns a new conditional FPTree if one can be created.\n            var childTree = tree.getConditionalFPTree(item);\n            // If a conditional tree can be mined... mine it recursively.\n            if (childTree)\n                return itemsets.concat(_this._fpGrowth(childTree, support, currentPrefix));\n            return itemsets;\n        }, []);\n    };\n    /**\n     * Handles the mining of frequent itemsets over a single path tree.\n     *\n     * @param  {FPNode<T>[]} singlePath The given single path.\n     * @param  {T[]}         prefix     The prefix associated with the path.\n     * @return {Itemset<T>}             The mined itemsets.\n     */\n    FPGrowth.prototype._handleSinglePath = function (singlePath, prefix) {\n        // TODO\n        return [];\n    };\n    /**\n     * Returns and emit through an event a formatted mined frequent itemset.\n     *\n     * @param  {T[]}        itemset The items of the frequent itemset.\n     * @param  {number}     support The support of the itemset.\n     * @return {Itemset<T>}         The formatted itemset.\n     */\n    FPGrowth.prototype._getFrequentItemset = function (itemset, support) {\n        var ret = {\n            items: itemset,\n            support: support\n        };\n        this.emit('data', ret);\n        return ret;\n    };\n    /**\n     * Returns the occurence of single items in a given set of transactions.\n     *\n     * @param  {T[][]}      transactions The set of transaction.\n     * @return {ItemsCount}              Count of items (stringified items as keys).\n     */\n    FPGrowth.prototype._getDistinctItemsCount = function (transactions) {\n        return transactions.reduce(function (count, arr) {\n            return arr.reduce(function (count, item) {\n                count[JSON.stringify(item)] = (count[JSON.stringify(item)] || 0) + 1;\n                return count;\n            }, count);\n        }, {});\n    };\n    return FPGrowth;\n}(events_1.EventEmitter));\nexports.FPGrowth = FPGrowth;\n"]}