build/modelscript.cjs.js
function assocationRuleLearning(transactions =[], options) {
  return new Promise((resolve, reject) => {
    try {
      const config = Object.assign({}, {
        support: 0.4,
        minLength: 2,
        summary: true,
        valuesMap: new Map(),
      }, options);
      const fpgrowth = new FPGrowth(config.support);
      fpgrowth.exec(transactions)
        .then(results => {
          const itemsets = (results.itemsets) ? results.itemsets : results;
          // console.log('itemsets', itemsets)
          if (config.summary) {
            resolve(itemsets
              .map(itemset => ({
                items_labels: itemset.items.map(item => config.valuesMap.get(item)),
                items: itemset.items,
                support: itemset.support,
                support_percent: itemset.support / transactions.length,
              }))
              .filter(itemset => itemset.items.length > 1)
              .sort((a, b) => b.support - a.support));
          } else {
            resolve(results);
          }
        })
        .catch(reject);
    } catch (e) {
      reject(e);
    }
  });
}
function assocationRuleLearning(transactions =[], options) {
  return new Promise((resolve, reject) => {
    try {
      const config = Object.assign({}, {
        support: 0.4,
        minLength: 2,
        summary: true,
        valuesMap: new Map(),
      }, options);
      const fpgrowth = new FPGrowth(config.support);
      fpgrowth.exec(transactions)
        .then(results => {
          const itemsets = (results.itemsets) ? results.itemsets : results;
          // console.log('itemsets', itemsets)
          if (config.summary) {
            resolve(itemsets
              .map(itemset => ({
                items_labels: itemset.items.map(item => config.valuesMap.get(item)),
                items: itemset.items,
                support: itemset.support,
                support_percent: itemset.support / transactions.length,
              }))
              .filter(itemset => itemset.items.length > 1)
              .sort((a, b) => b.support - a.support));
          } else {
            resolve(results);
          }
        })
        .catch(reject);
    } catch (e) {
      reject(e);
    }
  });
}
function assocationRuleLearning ( transactions = [ ] , options ) { return new Promise ( ( resolve , reject ) => { try { const config = Object . assign ( { } , { support : 0.4 , minLength : 2 , summary : true , valuesMap : new Map ( ) , } , options ) ; const fpgrowth = new FPGrowth ( config . support ) ; fpgrowth . exec ( transactions ) . then ( results => { const itemsets = ( results . itemsets ) ? results . itemsets : results ; // console.log('itemsets', itemsets)
 if ( config . summary ) { resolve ( itemsets . map ( itemset => ( { items_labels : itemset . items . map ( item => config . valuesMap . get ( item ) ) , items : itemset . items , support : itemset . support , support_percent : itemset . support / transactions . length , } ) ) . filter ( itemset => itemset . items . length > 1 ) . sort ( ( a , b ) => b . support - a . support ) ) ; } else { resolve ( results ) ; } } ) . catch ( reject ) ; } catch ( e ) { reject ( e ) ; } } ) ; }
returns association rule learning results
@memberOf calc
@see {@link https://github.com/alexisfacques/Node-FPGrowth}
@param {Array} transactions - sparse matrix of transactions
@param {Object} options
@param {Number} [options.support=0.4] - support level
@param {Number} [options.minLength=2] - minimum assocation array size
@param {Boolean} [options.summary=true] - return summarized results
@param {Map} [options.valuesMap=new Map()] - map of values and labels (used for summary results)
@returns {Object} Returns the result from Node-FPGrowth or a summary of support and strong associations
returns association rule learning results