def test_estimate_mixture2(self): mixt20 = Estimate(ExtractHistogram(self.data, 5), "MIXTURE", "NB", "NB", "NB", "NB", NbComponent="Estimated") assert mixt20.nb_component == 3
def test_mixture(self): h = Histogram(get_shared_data("meri2.his")) mixt = h.estimate_mixture(["B", "NB"]) assert ExtractHistogram(mixt, "Weight") == \ mixt.extract_weight() assert ExtractHistogram(mixt, "Mixture") == \ mixt.extract_mixture() assert ExtractHistogram(mixt, "Component", 1) == \ mixt.extract_component(1) assert ExtractHistogram(mixt, "Component", 2) == \ mixt.extract_component(2) try: ExtractHistogram(mixt, "Component", 3) assert False except: # Bas distrubition index assert True
def test_sequences(): ExtractHistogram(seq20, "Recurrence", 1) ExtractHistogram(seq20, "Recurrence", 2) ExtractHistogram(seq20, "Length") ExtractHistogram(seq11, "FirstOccurrence", 1, 0) ExtractHistogram(seq0, "Value", 3) ExtractHistogram(seq_cluster, "Value", 1) ExtractHistogram(seq_cluster, "Value", 2)
def test_vectors(): ExtractHistogram(vec95, 2)
def test_vectors(self): v = Vectors([[1, 2, 3, 4, 5, 6, 7]]) ExtractHistogram(v, 1) v = Vectors([[1, 2], [3, 4]]) ExtractHistogram(v, 1)
def test_compound(self): comp = Compound("data/compound1.cd") comp_histo = Simulate(comp, 200) _histo = ExtractHistogram(comp_histo, "Sum") _histo = ExtractHistogram(comp_histo, "Elementary")
def test_convolution(self): convol = Convolution("data/convolution1.conv") convol_histo = Simulate(convol, 200) _histo = ExtractHistogram(convol_histo, "Elementary", 1) _histo = ExtractHistogram(convol_histo, "Convolution")
def test_compare(self): seq = self.data res = Compare(ExtractHistogram(seq[0], 2), ExtractHistogram(seq[1], 2), ExtractHistogram(seq[2], 2), "N") assert res
def test(): vec10 = Vectors("data/chene_sessile.vec") Plot(vec10) # plot of the pointwise averages Plot(Regression(vec10, "MovingAverage", 1, 2, [1])) vec95 = ValueSelect(vec10, 1, 1995) vec96 = ValueSelect(vec10, 1, 1996) vec97 = ValueSelect(vec10, 1, 1997) VarianceAnalysis(vec10, 1, 2, "N") Compare(ExtractHistogram(vec95, 2), ExtractHistogram(vec96, 2), \ ExtractHistogram(vec95, 2), "N") Plot(ExtractHistogram(vec95, 2), ExtractHistogram(vec96, 2), \ ExtractHistogram(vec97, 2)) ContingencyTable(vec10, 1, 4) # one-way variance analysis based on ranks VarianceAnalysis(vec10, 1, 4, "O") Compare(ExtractHistogram(vec95, 4), ExtractHistogram(vec96, 4), \ ExtractHistogram(vec95, 4), "O") # looks like it is not plotted Plot(ExtractHistogram(vec95, 4), ExtractHistogram(vec96, 4), ExtractHistogram(vec97, 4)) Plot(ExtractHistogram(vec95, 5), ExtractHistogram(vec96, 5), ExtractHistogram(vec97, 5)) Plot(ExtractHistogram(vec95, 6), ExtractHistogram(vec96, 6), ExtractHistogram(vec97, 6)) vec11 = ValueSelect(vec10, 4, 1) vec12 = ValueSelect(vec10, 4, 2) vec13 = ValueSelect(vec10, 4, 3, 4) Plot(ExtractHistogram(vec11, 2), ExtractHistogram(vec12, 2), ExtractHistogram(vec13, 2)) Plot(ExtractHistogram(vec11, 5), ExtractHistogram(vec12, 5), ExtractHistogram(vec13, 5)) mixt20 = Estimate(ExtractHistogram(vec10, 2), \ "MIXTURE", "NB", "NB", "NB", "NB", \ NbComponent="Estimated") Display(mixt20) Plot(mixt20) Plot(ExtractDistribution(mixt20, "Mixture")) _mixt21 = Estimate(ExtractHistogram(vec10, 5), \ "MIXTURE", "NB", "NB", "NB", "NB", \ NbComponent="Estimated") vec9596 = ValueSelect(vec10, 1, 1995, 1996) Plot(ExtractHistogram(ValueSelect(vec9596, 4, 1), 6), \ ExtractHistogram(ValueSelect(vec9596, 4, 2), 6), \ ExtractHistogram(ValueSelect(vec9596, 4, 3, 4), 6)) # linear regression regress10 = Regression(vec10, "Linear", 5, 2) Display(regress10) Plot(regress10) # nonparametric regression (loess smoother) _regress11 = Regression(vec10, "NearestNeighbors", 5, 2, 0.3) _regress12 = Regression(vec9596, "Linear", 5, 6) _regress13 = Regression(vec9596, "NearestNeighbors", 5, 6, 0.5) _vec15 = SelectVariable(vec10, [1, 3, 6], Mode="Reject")
def test2(): """finite mixture of discrete distributions""" mixt1 = Mixture("data//mixture1.mixt") mixt1 = Mixture(0.6, Distribution("B", 2, 18, 0.5), 0.4, Distribution("NB", 10, 10, 0.5)) mixt_histo1 = Simulate(mixt1, 200) Plot(mixt_histo1) # extraction of histograms/frequency distributions corresponding # to a given mixture component # (i.e. elementary distributions which are combined by mixture) histo10 = ExtractHistogram(mixt_histo1, "Component", 1) histo11 = ExtractHistogram(mixt_histo1, "Component", 2) _histo12 = Merge(histo10, histo11) _histo13 = ExtractHistogram(mixt_histo1, "Weight") # estimation mixt2 = Estimate(mixt_histo1, "MIXTURE", "B", "NB", MinInfBound=0, InfBoundStatus="Fixed", DistInfBoundStatus="Fixed") _mixt_histo2 = ExtractData(mixt2) _histo14 = ExtractHistogram(ExtractData(mixt2), "Component", 1) _histo15 = ToHistogram(ExtractDistribution(mixt2, "Component", 1)) # estimation and selection of the number of components meri1 = Histogram(get_shared_data("meri1.his")) meri2 = Histogram(get_shared_data("meri2.his")) meri3 = Histogram(get_shared_data("meri3.his")) meri4 = Histogram(get_shared_data("meri4.his")) meri5 = Histogram(get_shared_data("meri5.his")) #mixt3 = Estimate(meri1, "MIXTURE", Distribution("B", 6, 7, 0.5), "B") mixt3 = Estimate(meri1, "MIXTURE", "B", "B") Plot(mixt3) # NbComponent="Fixed" (default) / "Estimated" # Penalty="AIC"/ "AICc" / "BIC" / "BICc" (default), option # valide if NbComponent="Estimated" meri = Merge(meri1, meri2, meri3, meri4, meri5) mixt2 = Estimate(meri, "MIXTURE", "B", "B", "B", "B", NbComponent="Estimated", Penalty="BIC") Display(mixt2, Detail=2) dist_mixt = ExtractDistribution(mixt2, "Mixture") Plot(dist_mixt)