Sha256: 97b0d72d8765b769ca2a5636a3ee79842dbd550846ea3f532484bbf747af0a90

Contents?: true

Size: 558 Bytes

Versions: 4

Compression:

Stored size: 558 Bytes

Contents

module CohortAnalysis
  class Strategy
    class Big < Strategy
      # Reduce characteristics by removing them one by one and counting the results.
      #
      # The characteristic whose removal leads to the highest record count is removed from the overall characteristic set.
      def reduce!
        @current = if current.keys.length < 2
          {}
        else
          most_restrictive = current.keys.max_by do |k|
            count current.except(k)
          end
          current.except most_restrictive
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cohort_analysis-1.0.3 lib/cohort_analysis/strategy/big.rb
cohort_analysis-1.0.2 lib/cohort_analysis/strategy/big.rb
cohort_analysis-1.0.1 lib/cohort_analysis/strategy/big.rb
cohort_analysis-1.0.0 lib/cohort_analysis/strategy/big.rb