Package: cause-effect
Install itYou can installcause_effectvia:$pipinstallcause_effectAlternatively, you can install from the code repository directly:$pipinstallhg+http://bitbucket.org/hyllos/cause_effectCore Functionspareto(values)Is a pareto distribution present for a list of numbers (ratio<= 1)?mccauses(values)Which causes have the highest concentration (rank * value)?mceffects(values)Which effects have the highest concentration?separator(values)`From which value (including) does the highest concentration begin?causes(values, effects=0.8)Determine causes for specified share of effects.effects(values, causes=0.2)Determine effects for specified share of causes.Secondary Functionsratio(values)entropydivided bycontrol_limit.entropy(values)Calculate entropy for values.control_limit(count)Calculate control entropy forcountnumber of elements (length ofvalues).Tertiary Functionsmake_causes(count)Return list of causes that is cumulative percent ofcountnumber of elements.make_effects(values)Return list of effects that is cumulative percent of values.make_concentration(values)Return list of concentration for list ofvaluesthat is rank * value.sort_list(values)Return sorted list of numbers.Parametersvaluesis a list of numbers.effectsandcausesmust be a number between 0 and 1 (including).countis the length of the list ofvalues.Use itThe functionparetotells you whether a pareto distribution is present for a list of numbers:fromparetoimportpareto,mccauses,mceffectspareto([789,621,109,65,45,30,27,15,12,9])TrueHere, we have a pareto distribution present.
That is a minority causes a majority of effects.But which minority causes which majority?mccauses([789,621,109,65,45,30,27,15,12,9])0.2mceffects([789,621,109,65,45,30,27,15,12,9])0.81881533101045320% of causes effect 82% of results.But which values are that 20%?separator([789,621,109,65,45,30,27,15,12,9])621All values greater or equal than 621 are those 20% causing 82% of results.That’s it.Dig DeeperHow many causes are required for only 90% of effects?fromparetoimportcauses,effectscauses([789,621,109,65,45,30,27,15,12,9],0.9)0.440%.How many effects are behind only 10% of causes?effects([789,621,109,65,45,30,27,15,12,9],0.1)0.45845.8%.How does it work?paretocalculates theentropyfor a list of effects:fromparetoimportentropy,control_limit,ratioentropy([789,621,109,65,45,30,27,15,12,9])1.9593816735406657It calculates the entropy for a control group of ten elements. That is the length of our list.control_limit(10)2.7709505944546686It then checksentropyis less or equal thancontrol_limit.This can be simplified to:values=[789,621,109,65,45,30,27,15,12,9]entropy(values)/control_limit(len(values))<=1The left side of the comparison is done byratio.
So, if you want to find out how nearby or far off you are from a pareto distribution, do:ratio([109,65,45,30,27,15,12,9])1.051If we remove the first two effects, thecontrol_limitwill be exceeded by the values.
So, we learn here that the pareto distribution disappears with the first two effects.mccausesandmceffectsreturn the respective share of the causes and effects where concentration (rank * value) is highest.History0.2.0 (2016-10-21)Add function separator().Streamline tests.0.1.0 (2016-10-20)First release on PyPI.