├── .github └── workflows │ ├── JMixtComp.yml │ ├── MixtComp.yml │ ├── RMixtComp-eigen34.yml │ ├── RMixtComp.yml │ └── pyMixtComp.yml ├── .gitignore ├── .gitmodules ├── JMixtComp ├── README.md ├── build.sh ├── clean.sh ├── data │ ├── 00-SimpleCase │ │ ├── learn │ │ │ ├── algo.json │ │ │ ├── data.json │ │ │ └── desc.json │ │ └── predict │ │ │ ├── algo.json │ │ │ ├── data.json │ │ │ └── desc.json │ ├── 01-FunctionalCase │ │ ├── learn │ │ │ ├── algo.json │ │ │ ├── data.json │ │ │ └── desc.json │ │ └── predict │ │ │ ├── algo.json │ │ │ ├── data.json │ │ │ └── desc.json │ └── 02-RankCase │ │ ├── learn │ │ ├── algo.json │ │ ├── data.json │ │ └── desc.json │ │ └── predict │ │ ├── algo.json │ │ ├── data.json │ │ └── desc.json ├── runTest.sh ├── src │ ├── CMakeLists.txt │ ├── CMakeLists.txt.in │ ├── lib │ │ ├── CMakeLists.txt │ │ ├── JSONGraph.cpp │ │ ├── JSONGraph.h │ │ ├── jmc.cpp │ │ ├── jsonIO.h │ │ ├── translateCPPToJSON.h │ │ └── translateJSONToCPP.h │ └── utest │ │ ├── CMakeLists.txt │ │ └── JSONGraph.cpp ├── utest.sh └── valgrindRun.sh ├── LICENCE.md ├── MixtComp ├── .clang-format ├── .gitignore ├── README.md ├── TODO.md ├── archive │ ├── IO │ │ ├── AlgType.h │ │ ├── AlgTypeVisitor.cpp │ │ ├── AlgTypeVisitor.h │ │ ├── Dummy.cpp │ │ ├── Dummy.h │ │ ├── SGraph.cpp │ │ └── SGraph.h │ ├── JSONToSGraph.cpp │ ├── Makefile │ ├── Makevars │ ├── SGraphVisJSON.cpp │ └── json │ │ ├── AlgTypeVisJSON.cpp │ │ ├── AlgTypeVisJSON.h │ │ ├── JSONToSGraph.cpp │ │ ├── JSONToSGraph.h │ │ └── SGraphToJSON.h ├── build.sh ├── clean.sh ├── compile_commands.json ├── docs │ ├── Graph.md │ ├── SimpleMixture.md │ ├── algoDesc.md │ ├── article │ │ ├── BigStat.pdf │ │ ├── SEM.pdf │ │ ├── discriminativeLevelAndSimilarity.pdf │ │ ├── functionalModel.pdf │ │ ├── massiccc.pdf │ │ ├── ordinalModel.pdf │ │ ├── rankModel.pdf │ │ └── similarityClass.pdf │ ├── dataFormat.md │ ├── dev │ │ ├── 140101 - proposal │ │ │ ├── ProjectSpecifications.txt │ │ │ ├── Proposal.pdf │ │ │ ├── Proposal.tex │ │ │ ├── SoftwareDesign │ │ │ │ ├── architecture.dia │ │ │ │ └── architecture.png │ │ │ ├── StatisticalDocumentation │ │ │ │ ├── DiagonalMixtures.pdf │ │ │ │ ├── DiagonalMixtures.tex │ │ │ │ └── mixture-doc.bib │ │ │ ├── ens-ustl.cls │ │ │ ├── frameworkspecification.pdf │ │ │ ├── frameworkspecification.tex │ │ │ └── legacy │ │ │ │ └── doxygen │ │ │ │ └── MixtComp.doxyfile │ │ ├── 150817 - ProgrammersGuide │ │ │ ├── doc.pdf │ │ │ └── doc.tex │ │ ├── 170616 - mise à jour majeure │ │ │ ├── 1 - feuille de route.pdf │ │ │ ├── 2 - avancement modifications.pdf │ │ │ ├── 3 - tests intermédiaires.pdf │ │ │ ├── 4 - probabilités observées.pdf │ │ │ ├── 5 - présentation.pdf │ │ │ └── 6 - documentation scientifique.pdf │ │ └── 180308 - Initialization │ │ │ └── recap.ods │ ├── developmentEnvironment.md │ ├── error.md │ ├── howToAddModel.md │ ├── howToAddModelInR.md │ ├── math.md │ ├── objectOutput.md │ └── parallelism.md ├── src │ ├── CMakeLists.txt │ ├── CMakeLists.txt.in │ ├── CodeCoverage.cmake │ ├── archive │ │ ├── IO │ │ │ ├── UTestAlgTypeVisitor.cpp │ │ │ └── UTestSGraph.cpp │ │ ├── SGraphToJSON.cpp │ │ ├── model Ordinal │ │ │ ├── mixt_BOSNode.cpp │ │ │ ├── mixt_BOSNode.h │ │ │ ├── mixt_BOSPath.cpp │ │ │ ├── mixt_BOSPath.h │ │ │ └── mixt_Ordinal.h │ │ └── utest Ordinal │ │ │ ├── UTestBOSNode.cpp │ │ │ ├── UTestBOSPath.cpp │ │ │ └── UTestOrdinal.cpp │ ├── lib │ │ ├── CMakeLists.txt │ │ ├── Composer │ │ │ ├── ClassDataStat.cpp │ │ │ ├── ClassDataStat.h │ │ │ ├── ClassSampler.cpp │ │ │ ├── ClassSampler.h │ │ │ ├── MixtureComposer.cpp │ │ │ ├── MixtureComposer.h │ │ │ ├── ZClassInd.cpp │ │ │ └── ZClassInd.h │ │ ├── Data │ │ │ ├── AugmentedData.cpp │ │ │ ├── AugmentedData.h │ │ │ └── ConfIntDataStat.h │ │ ├── IO │ │ │ ├── IO.h │ │ │ ├── IOFunctions.cpp │ │ │ ├── IOFunctions.h │ │ │ ├── MisValParser.h │ │ │ ├── NamedAlgebra.h │ │ │ ├── SpecialStr.cpp │ │ │ └── SpecialStr.h │ │ ├── LinAlg │ │ │ ├── ConstIterator.h │ │ │ ├── EigenMatrixBaseAddons.h │ │ │ ├── Iterator.h │ │ │ ├── LinAlg.h │ │ │ ├── Maths.cpp │ │ │ ├── Maths.h │ │ │ ├── Typedef.cpp │ │ │ ├── Typedef.h │ │ │ ├── names.cpp │ │ │ └── names.h │ │ ├── Manager │ │ │ └── createAllMixtures.h │ │ ├── MixtComp.h │ │ ├── Mixture │ │ │ ├── Functional │ │ │ │ ├── FuncCSClass.cpp │ │ │ │ ├── FuncCSClass.h │ │ │ │ ├── FuncCSComputation.cpp │ │ │ │ ├── FuncCSComputation.h │ │ │ │ ├── FuncCSMixture.h │ │ │ │ ├── FuncCSProblem.h │ │ │ │ ├── FuncSharedAlphaCSMixture.h │ │ │ │ ├── FunctionCS.cpp │ │ │ │ ├── FunctionCS.h │ │ │ │ ├── FunctionCSParser.cpp │ │ │ │ └── FunctionCSParser.h │ │ │ ├── IMixture.h │ │ │ ├── Rank │ │ │ │ ├── RankISRClass.cpp │ │ │ │ ├── RankISRClass.h │ │ │ │ ├── RankISRIndividual.cpp │ │ │ │ ├── RankISRIndividual.h │ │ │ │ ├── RankISRMixture.h │ │ │ │ ├── RankISRParser.cpp │ │ │ │ ├── RankISRParser.h │ │ │ │ ├── RankISRStat.cpp │ │ │ │ ├── RankISRStat.h │ │ │ │ ├── RankVal.cpp │ │ │ │ └── RankVal.h │ │ │ └── Simple │ │ │ │ ├── Gaussian │ │ │ │ ├── Gaussian.cpp │ │ │ │ ├── Gaussian.h │ │ │ │ ├── GaussianLikelihood.cpp │ │ │ │ ├── GaussianLikelihood.h │ │ │ │ ├── GaussianSampler.cpp │ │ │ │ └── GaussianSampler.h │ │ │ │ ├── Multinomial │ │ │ │ ├── Multinomial.cpp │ │ │ │ ├── Multinomial.h │ │ │ │ ├── MultinomialDataStat.cpp │ │ │ │ ├── MultinomialDataStat.h │ │ │ │ ├── MultinomialLikelihood.h │ │ │ │ ├── MultinomialSampler.cpp │ │ │ │ └── MultinomialSampler.h │ │ │ │ ├── NegativeBinomial │ │ │ │ ├── NegativeBinomial.cpp │ │ │ │ ├── NegativeBinomial.h │ │ │ │ ├── NegativeBinomialLikelihood.cpp │ │ │ │ ├── NegativeBinomialLikelihood.h │ │ │ │ ├── NegativeBinomialSampler.cpp │ │ │ │ ├── NegativeBinomialSampler.h │ │ │ │ ├── NegativeBinomialStatistic.cpp │ │ │ │ └── NegativeBinomialStatistic.h │ │ │ │ ├── Poisson │ │ │ │ ├── Poisson.cpp │ │ │ │ ├── Poisson.h │ │ │ │ ├── PoissonLikelihood.cpp │ │ │ │ ├── PoissonLikelihood.h │ │ │ │ ├── PoissonSampler.cpp │ │ │ │ ├── PoissonSampler.h │ │ │ │ ├── PoissonStatistic.cpp │ │ │ │ └── PoissonStatistic.h │ │ │ │ ├── SimpleMixture.h │ │ │ │ └── Weibull │ │ │ │ ├── Weibull.cpp │ │ │ │ ├── Weibull.h │ │ │ │ ├── WeibullLikelihood.cpp │ │ │ │ ├── WeibullLikelihood.h │ │ │ │ ├── WeibullSampler.cpp │ │ │ │ ├── WeibullSampler.h │ │ │ │ ├── WeibullStatistic.cpp │ │ │ │ └── WeibullStatistic.h │ │ ├── Param │ │ │ └── ConfIntParamStat.h │ │ ├── Run │ │ │ ├── Learn.h │ │ │ └── Predict.h │ │ ├── Statistic │ │ │ ├── ExponentialStatistic.cpp │ │ │ ├── ExponentialStatistic.h │ │ │ ├── Functions.h │ │ │ ├── GaussianStatistic.cpp │ │ │ ├── GaussianStatistic.h │ │ │ ├── MultinomialStatistic.cpp │ │ │ ├── MultinomialStatistic.h │ │ │ ├── RNG.cpp │ │ │ ├── RNG.h │ │ │ ├── Statistic.h │ │ │ ├── UniformIntStatistic.cpp │ │ │ ├── UniformIntStatistic.h │ │ │ ├── UniformStatistic.cpp │ │ │ └── UniformStatistic.h │ │ ├── Strategy │ │ │ ├── GibbsStrategy.h │ │ │ └── SEMStrategy.h │ │ └── Various │ │ │ ├── Constants.cpp │ │ │ ├── Constants.h │ │ │ ├── Enum.h │ │ │ ├── Timer.cpp │ │ │ ├── Timer.h │ │ │ ├── Various.cpp │ │ │ └── Various.h │ └── utest │ │ ├── CMakeLists.txt │ │ ├── CMakeLists.txt.in │ │ ├── Composer │ │ └── UTestZClassInd.cpp │ │ ├── Functional │ │ ├── UTestFuncCSClass.cpp │ │ ├── UTestFuncCSComputation.cpp │ │ ├── UTestFuncCSMixture.cpp │ │ ├── UTestFunctionCS.cpp │ │ ├── UTestFunctionCSParser.cpp │ │ └── UTestOptim.cpp │ │ ├── IO │ │ └── MisValParser.cpp │ │ ├── LinAlgStat │ │ ├── UTestLinAlg.cpp │ │ ├── UTestMath.cpp │ │ ├── UTestStatistics.cpp │ │ └── names.cpp │ │ ├── Rank │ │ ├── UTestRankISRClass.cpp │ │ ├── UTestRankISRIndividual.cpp │ │ ├── UTestRankISRParser.cpp │ │ ├── UTestRankISRStat.cpp │ │ └── UTestRankVal.cpp │ │ ├── Simple │ │ ├── UTestGaussian.cpp │ │ ├── UTestMultinomial.cpp │ │ ├── UTestNegativeBinomial.cpp │ │ ├── UTestPoisson.cpp │ │ └── UTestWeibull.cpp │ │ ├── Statistic │ │ ├── UTestGaussianStatistic.cpp │ │ ├── UTestMultinomialStatistic.cpp │ │ ├── UTestNegativeBinomialStatistic.cpp │ │ ├── UTestPoissonStatistic.cpp │ │ ├── UTestRNG.cpp │ │ ├── UTestUniformIntStatistic.cpp │ │ └── UTestWeibullStatistic.cpp │ │ └── Various │ │ ├── UTestMisValParser.cpp │ │ ├── UTestRegex.cpp │ │ ├── UTestStandardLibrary.cpp │ │ └── UTestVarious.cpp ├── utest.sh ├── utestCoverage.sh └── valgrindRun.sh ├── README.md ├── RJMixtComp ├── .Rbuildignore ├── BinaryFiles ├── DESCRIPTION ├── NAMESPACE ├── R │ ├── JsonMixtComp.R │ ├── convertJsonToRobject.R │ ├── convertRobjectToJson.R │ └── packageDescription.R ├── README.md ├── RJMixtComp.Rproj ├── inst │ ├── exeMixtComp │ │ └── empty │ └── extdata │ │ ├── data.json │ │ ├── desc.json │ │ ├── functionalData.RData │ │ └── rankData.RData ├── man │ ├── JMixtCompLearn.Rd │ └── RJMixtComp-package.Rd ├── tests │ ├── testthat.R │ └── testthat │ │ ├── test.format.R │ │ ├── test.run.R │ │ └── test.writingJson.R └── update.sh ├── RMixtComp ├── .Rbuildignore ├── DESCRIPTION ├── NAMESPACE ├── NEWS ├── R │ ├── MIXTCOMP_datasets.R │ ├── MIXTCOMP_formatData.R │ ├── MIXTCOMP_hierarchical.R │ ├── MIXTCOMP_methods.R │ ├── MIXTCOMP_mixtCompLearn.R │ ├── PLOT_plotCrit.R │ ├── RMixtComp-package.R │ ├── miscellaneous.R │ └── slopeHeuristic.R ├── README.md ├── RMixtComp.Rproj ├── data │ ├── CanadianWeather.rda │ ├── prostate.rda │ ├── simData.rda │ └── titanic.rda ├── genDataPackage.R ├── man │ ├── CanadianWeather.Rd │ ├── RMixtComp-package.Rd │ ├── extractMixtCompObject.Rd │ ├── mixtCompLearn.Rd │ ├── plot.MixtCompLearn.Rd │ ├── plotCrit.Rd │ ├── predict.MixtComp.Rd │ ├── print.MixtCompLearn.Rd │ ├── prostate.Rd │ ├── simData.Rd │ ├── slopeHeuristic.Rd │ ├── summary.MixtCompLearn.Rd │ └── titanic.Rd ├── tests │ ├── testthat.R │ └── testthat │ │ ├── test.hierarchical.R │ │ ├── test.miscellaneous.R │ │ ├── test.parameterPretreatment.R │ │ ├── test.run.R │ │ ├── test.runWrapper.R │ │ └── test.slopeHeuristic.R └── vignettes │ ├── ClusVis.Rmd │ ├── MixtComp.Rmd │ ├── dataFormat.Rmd │ └── mixtCompObject.Rmd ├── RMixtCompHier ├── .Rbuildignore ├── DESCRIPTION ├── NAMESPACE ├── R │ ├── RMixtCompHier-package.R │ ├── aggregate_results.r │ ├── concatenate.R │ ├── data_processing_for_mixtcomp.r │ ├── generate_data.r │ ├── hierarchicalNewMixtComp.R │ ├── mixtcomp_hierachical_launch.r │ ├── toolbox.R │ └── visualisation.r ├── README.md ├── RMixtCompHier.Rproj ├── inst │ └── exe │ │ └── JsonMixtComp ├── man │ ├── RMixtCompHier-package.Rd │ ├── aggregate_classification_probabilities.Rd │ ├── aggregate_clusters.Rd │ ├── aggregate_completed.Rd │ ├── convertFunctional.Rd │ ├── createFunctional.Rd │ ├── getData.Rd │ ├── launch_Mixtcomp_Hierarchical.Rd │ ├── launch_Mixtcomp_Hierarchical_predict.Rd │ ├── linesFunctional.Rd │ ├── plotFunctional.Rd │ ├── plot_categorical_hierarchique.Rd │ ├── plot_functional_hierarchique.Rd │ ├── plot_proportion_hierarchique.Rd │ ├── plot_quality_pred_hierarchique.Rd │ └── prune_hierarchy.Rd └── tests │ ├── testthat.R │ └── testthat │ ├── test.concatenate.R │ ├── test.r │ └── test_hierachical_launch.r ├── RMixtCompIO ├── .Rbuildignore ├── DESCRIPTION ├── LICENSE.note ├── Makefile ├── NAMESPACE ├── NEWS ├── R │ ├── GENDATA_dataGeneratorNewIO.R │ ├── GENDATA_functionalGenerator.R │ ├── GENDATA_functionalInterPolyGenerator.R │ ├── GENDATA_ordinalGenerator.R │ ├── GENDATA_rankGenerator.R │ ├── GENDATA_simpleModelGenerator.R │ ├── RMixtCompIO-package.R │ ├── TEST_SimpleNormalTest.R │ ├── TEST_functional.R │ ├── TEST_functionalSharedAlpha.R │ ├── TEST_paramModel.R │ ├── TEST_zParam.R │ └── rmcMultiRun.R ├── README.md ├── RMixtCompIO.Rproj ├── build.sh ├── cleanup ├── inst │ └── COPYRIGHTS ├── man │ ├── RMixtCompIO-package.Rd │ └── rmcMultiRun.Rd ├── src │ ├── CPPToRMatrixType.h │ ├── CPPToRVectorType.h │ ├── RGraph.cpp │ ├── RGraph.h │ ├── UTest.cpp │ ├── rmc.cpp │ ├── test │ │ └── test.cpp │ ├── translateCPPToR.h │ └── translateRToCPP.h ├── tests │ ├── testthat.R │ └── testthat │ │ ├── test.index.R │ │ ├── test.io.R │ │ ├── test.multirun.R │ │ ├── test.run.R │ │ └── test.simpleRun.R └── updateLib.py ├── RMixtCompUtilities ├── .Rbuildignore ├── DESCRIPTION ├── NAMESPACE ├── NEWS ├── R │ ├── CLUSVIS_plotClasses.R │ ├── MIXTCOMP_formatFunctions.R │ ├── MIXTCOMP_formatParameter.R │ ├── MIXTCOMP_getParam.R │ ├── MIXTCOMP_getter.R │ ├── MIXTCOMP_methods.R │ ├── MIXTCOMP_misc.R │ ├── PLOT_barplot.R │ ├── PLOT_extractCIbounds.R │ ├── PLOT_functionalBounds.R │ ├── PLOT_heatmap.R │ ├── PLOT_histAndLine.R │ ├── PLOT_plotConvergence.R │ ├── PLOT_plotUnivariateBoxplots.R │ ├── PLOT_plotUnivariateDistributions.R │ └── RMixtCompUtilities-package.R ├── README.md ├── RMixtCompUtilities.Rproj ├── man │ ├── RMixtCompUtilities-package.Rd │ ├── availableModels.Rd │ ├── completeAlgo.Rd │ ├── computeDiscrimPowerVar.Rd │ ├── computeSimilarityVar.Rd │ ├── convertFunctionalToVector.Rd │ ├── createAlgo.Rd │ ├── createFunctional.Rd │ ├── formatData.Rd │ ├── formatModel.Rd │ ├── getBIC.Rd │ ├── getCompletedData.Rd │ ├── getEmpiricTik.Rd │ ├── getMixtureDensity.Rd │ ├── getParam.Rd │ ├── getPartition.Rd │ ├── getType.Rd │ ├── heatmapClass.Rd │ ├── heatmapTikSorted.Rd │ ├── heatmapVar.Rd │ ├── histMisclassif.Rd │ ├── plot.MixtComp.Rd │ ├── plotConvergence.Rd │ ├── plotDataBoxplot.Rd │ ├── plotDataCI.Rd │ ├── plotDiscrimClass.Rd │ ├── plotDiscrimVar.Rd │ ├── plotParamConvergence.Rd │ ├── plotProportion.Rd │ ├── print.MixtComp.Rd │ ├── refactorCategorical.Rd │ └── summary.MixtComp.Rd └── tests │ ├── testthat.R │ └── testthat │ ├── test.formatFunction.R │ ├── test.getParam.R │ ├── test.misc.R │ └── test.parameterPretreatment.R ├── architecture.md ├── ci.sh ├── graphArchitecture.png ├── graphArchitecture.xcf ├── mcCleanUpdate.sh ├── pyMixtComp ├── README.md ├── build.sh ├── clean.sh ├── python │ ├── README.md │ ├── build.sh │ ├── notebooks │ │ ├── functional-example.ipynb │ │ └── prostate-example.ipynb │ ├── pyMixtComp │ │ ├── MixtComp.py │ │ ├── __init__.py │ │ ├── bridge │ │ │ ├── bridge.py │ │ │ ├── convert.py │ │ │ └── utils.py │ │ ├── data │ │ │ ├── __init__.py │ │ │ ├── canadian_weather.csv │ │ │ ├── data.py │ │ │ ├── iris.csv │ │ │ ├── prostate.csv │ │ │ └── simulated_data.csv │ │ ├── plot │ │ │ ├── __init__.py │ │ │ ├── barplot.py │ │ │ ├── functional.py │ │ │ ├── heatmap.py │ │ │ ├── univariate_boxplot.py │ │ │ └── univariate_distribution.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ ├── convert.py │ │ │ ├── criterion.py │ │ │ ├── getter.py │ │ │ └── sample.py │ ├── pyproject.toml │ ├── requirements.txt │ └── tests │ │ ├── __init__.py │ │ ├── mixtcomp_output.pickle │ │ ├── mixtcomp_output_full.pickle │ │ ├── mixtcomp_output_functional.pickle │ │ ├── mixtcomp_output_functional_diff_time.pickle │ │ ├── test_MixtComp.py │ │ ├── test_bridge_convert.py │ │ ├── test_bridge_utils.py │ │ ├── test_data.py │ │ ├── test_plot.py │ │ ├── test_utils_convert.py │ │ ├── test_utils_getter.py │ │ └── test_utils_sample.py ├── src │ ├── CMakeLists.txt │ ├── lib │ │ ├── CMakeLists.txt │ │ ├── PyGraph.cpp │ │ ├── PyGraph.h │ │ ├── pmc.cpp │ │ ├── pmc.h │ │ ├── pyMixtComp.cpp │ │ ├── pythonIO.h │ │ ├── translateCPPToPython.h │ │ └── translatePythonToCPP.h │ └── utest │ │ ├── CMakeLists.txt │ │ └── UTestPyGraph.cpp └── utest.sh └── updateVersion.py /.github/workflows/JMixtComp.yml: -------------------------------------------------------------------------------- 1 | name: JMixtComp C++ Library 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - staging 7 | paths: 8 | - 'MixtComp/**' 9 | - '!MixtComp/docs/**' 10 | - 'JMixtComp/**' 11 | - '.github/workflows/JMixtComp.yml' 12 | - '!**/README.md' 13 | pull_request: 14 | branches: 15 | - master 16 | - staging 17 | paths: 18 | - 'MixtComp/**' 19 | - '!MixtComp/docs/**' 20 | - 'JMixtComp/**' 21 | - '.github/workflows/JMixtComp.yml' 22 | - '!**/README.md' 23 | 24 | jobs: 25 | build: 26 | runs-on: ubuntu-latest 27 | 28 | steps: 29 | - name: Checkout MixtComp 30 | uses: actions/checkout@v4 31 | with: 32 | submodules: 'true' 33 | - name: Install MixtComp dependencies 34 | run: sudo apt-get install cmake libboost-all-dev libeigen3-dev libxml2-dev lcov valgrind 35 | - name: Compile JMixtComp 36 | working-directory: JMixtComp 37 | run: ./build.sh Debug 38 | - name: Test JMixtComp 39 | working-directory: JMixtComp 40 | run: ./utest.sh 41 | - name: Run valgrind 42 | working-directory: JMixtComp 43 | run: ./valgrindRun.sh -------------------------------------------------------------------------------- /.github/workflows/MixtComp.yml: -------------------------------------------------------------------------------- 1 | name: MixtComp C++ Library 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - staging 7 | paths: 8 | - 'MixtComp/**' 9 | - '!MixtComp/docs/**' 10 | - '.github/workflows/MixtComp.yml' 11 | - '!**/README.md' 12 | pull_request: 13 | branches: 14 | - master 15 | - staging 16 | paths: 17 | - 'MixtComp/**' 18 | - '!MixtComp/docs/**' 19 | - '.github/workflows/MixtComp.yml' 20 | - '!**/README.md' 21 | 22 | jobs: 23 | build: 24 | runs-on: ubuntu-latest 25 | 26 | steps: 27 | - name: Checkout MixtComp 28 | uses: actions/checkout@v4 29 | with: 30 | submodules: 'true' 31 | - name: Install MixtComp dependencies 32 | run: sudo apt-get install cmake libboost-all-dev libeigen3-dev libxml2-dev lcov valgrind 33 | - name: Compile MixtComp 34 | working-directory: MixtComp 35 | run: ./build.sh Debug 36 | - name: Test MixtComp 37 | working-directory: MixtComp 38 | run: ./utest.sh 39 | - name: Run valgrind 40 | working-directory: MixtComp 41 | run: ./valgrindRun.sh 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .svn 2 | .DS_store 3 | .recommenders 4 | *.tar.gz 5 | .project 6 | .vscode 7 | .metadata/* 8 | /.metadata/ 9 | RemoteSystemsTempFiles 10 | 11 | # compiled objects 12 | *.o 13 | *.so 14 | *.a 15 | *.d 16 | 17 | # build 18 | report*.xml 19 | build/ 20 | MixtComp/log 21 | 22 | JMixtComp/data/*/learn/resLearn.json 23 | JMixtComp/data/*/predict/resPredict.json 24 | RJMixtComp/inst/exeMixtComp/jmc 25 | !RJMixtComp/inst/extdata/*.json 26 | 27 | # RMixtCompIO 28 | RMixtCompIO/R/RcppExports.R 29 | RMixtCompIO/src/RcppExports.cpp 30 | RMixtCompIO/src/Makevars 31 | RMixtCompIO/src/lib 32 | RMixtCompIO/src/test/test 33 | RMixtCompIO/src/libOFiles 34 | 35 | # latex 36 | *.aux 37 | *.bcf 38 | *.out 39 | *.toc 40 | *.log 41 | *.run.xml 42 | *.synctex.gz 43 | 44 | # R 45 | .Rproj.user 46 | .Rhistory 47 | .RData 48 | *.Rcheck 49 | 50 | # python 51 | __pycache__ 52 | *.egg-info 53 | dist/ 54 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "RMixtCompIO/src/optim"] 2 | path = RMixtCompIO/src/optim 3 | url = https://github.com/modal-inria/CppNumericalSolvers 4 | -------------------------------------------------------------------------------- /JMixtComp/README.md: -------------------------------------------------------------------------------- 1 | # JMixtComp 2 | 3 | ## Compile JMixtComp 4 | 5 | Run `./build.sh` to compile MixtComp in Debug mode. Run `./build.sh Release` or `./build.sh Coverage` to build in release mode or for code coverage. The build is performed in a build folder. 6 | Run `./utest.sh` to run unit tests . 7 | To clean the build folder, run `./clean.sh`. 8 | 9 | ## Executables 10 | 11 | After compiling, *jmc* executables can be found at the following location: `build/lib/jmc`. It allows to run MixtComp in command line with json as format for input and output files. 12 | 13 | ## Running jmc 14 | 15 | In learning mode, *jmc* requires four parameters: three input files (algo, data and desc, see [Data Format](../MixtComp/docs/dataFormat.md)) and the name of the output file. To have more information about the output format, read the associated [documentation](../MixtComp/docs/objectOutput.md). 16 | 17 | ```bash 18 | jmc algo.json data.json desc.json resLearn.json 19 | ``` 20 | 21 | In predict mode, *jmc* requires five parameters: four input files (algo, data and desc, see [Data Format](../MixtComp/docs/dataFormat.md) and a result of a learning run of *jmc*) and the name of the output file. 22 | 23 | ```bash 24 | jmc algo.json data.json desc.json resLearn.json resPredict.json 25 | ``` 26 | 27 | ## Examples 28 | 29 | Datasets can be found in the [data folder](data) and can be used with jmc by running the [runTest.sh](runTest.sh) file. 30 | -------------------------------------------------------------------------------- /JMixtComp/build.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build 2 | cd build 3 | if [ $# -eq 0 ] 4 | then 5 | cmake -DCMAKE_BUILD_TYPE=Debug ../src 6 | else 7 | cmake -DCMAKE_BUILD_TYPE=$1 ../src 8 | fi 9 | cmake --build . -------------------------------------------------------------------------------- /JMixtComp/clean.sh: -------------------------------------------------------------------------------- 1 | find build ! -name 'empty' -type f -exec rm -f {} + 2 | find build ! -name '.' -type d -exec rm -r -f {} + -------------------------------------------------------------------------------- /JMixtComp/data/00-SimpleCase/learn/algo.json: -------------------------------------------------------------------------------- 1 | { 2 | "nClass": 2, 3 | "nInd": 200, 4 | "nbBurnInIter": 100, 5 | "nbIter": 100, 6 | "nbGibbsBurnInIter": 100, 7 | "nbGibbsIter": 100, 8 | "nInitPerClass": 20, 9 | "nSemTry": 10, 10 | "confidenceLevel": 0.95, 11 | "ratioStableCriterion": 0.9, 12 | "nStableCriterion": 7, 13 | "mode": "learn", 14 | "notes": "You can add any note you wish in non mandatory fields like this one (notes). They will be copied to the output." 15 | } 16 | -------------------------------------------------------------------------------- /JMixtComp/data/00-SimpleCase/learn/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "Gaussian1": { 3 | "type": "Gaussian", 4 | "paramStr": "dummyStrTestGaussian" 5 | }, 6 | "Poisson1": { 7 | "type": "Poisson", 8 | "paramStr": "dummyStrTestPoisson" 9 | }, 10 | "Categorical1": { 11 | "type": "Multinomial", 12 | "paramStr": "" 13 | }, 14 | "nBinom1": { 15 | "type": "NegativeBinomial", 16 | "paramStr": "" 17 | }, 18 | "Weibull1": { 19 | "type": "Weibull", 20 | "paramStr": "" 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /JMixtComp/data/00-SimpleCase/predict/algo.json: -------------------------------------------------------------------------------- 1 | { 2 | "nClass": 2, 3 | "nInd": 2, 4 | "nbBurnInIter": 100, 5 | "nbIter": 100, 6 | "nbGibbsBurnInIter": 100, 7 | "nbGibbsIter": 100, 8 | "nInitPerClass": 2, 9 | "nSemTry": 10, 10 | "confidenceLevel": 0.95, 11 | "mode": "predict" 12 | } 13 | -------------------------------------------------------------------------------- /JMixtComp/data/00-SimpleCase/predict/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "Gaussian1": ["1.0", "10.0", "[4.98086:+inf]", "2.28"], 3 | "Poisson1": ["?", "12", "22", "5"], 4 | "Categorical1": ["1", "?", "2", "1"], 5 | "Weibull1": ["1.5", "10.5", "1.5019", "?"], 6 | "nBinom1": ["3", "11", "?", "4"] 7 | } 8 | -------------------------------------------------------------------------------- /JMixtComp/data/00-SimpleCase/predict/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "Gaussian1": { 3 | "type": "Gaussian", 4 | "paramStr": "" 5 | }, 6 | "Poisson1": { 7 | "type": "Poisson", 8 | "paramStr": "" 9 | }, 10 | "Categorical1": { 11 | "type": "Multinomial", 12 | "paramStr": "" 13 | }, 14 | "nBinom1": { 15 | "type": "NegativeBinomial", 16 | "paramStr": "" 17 | }, 18 | "Weibull1": { 19 | "type": "Weibull", 20 | "paramStr": "" 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /JMixtComp/data/01-FunctionalCase/learn/algo.json: -------------------------------------------------------------------------------- 1 | { 2 | "nClass": 2, 3 | "nInd": 200, 4 | "nbBurnInIter": 50, 5 | "nbIter": 50, 6 | "nbGibbsBurnInIter": 50, 7 | "nbGibbsIter": 50, 8 | "nInitPerClass": 50, 9 | "nSemTry": 20, 10 | "confidenceLevel": 0.95, 11 | "ratioStableCriterion": 0.95, 12 | "nStableCriterion": 10, 13 | "mode": "learn" 14 | } 15 | -------------------------------------------------------------------------------- /JMixtComp/data/01-FunctionalCase/learn/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "z_class": { 3 | "type": "LatentClass", 4 | "paramStr": "" 5 | }, 6 | "Functional1": { 7 | "type": "Func_CS", 8 | "paramStr": "nSub: 2, nCoeff: 2" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /JMixtComp/data/01-FunctionalCase/predict/algo.json: -------------------------------------------------------------------------------- 1 | { 2 | "nClass": 2, 3 | "nInd": 200, 4 | "nbBurnInIter": 50, 5 | "nbIter": 50, 6 | "nbGibbsBurnInIter": 50, 7 | "nbGibbsIter": 50, 8 | "nInitPerClass": 50, 9 | "nSemTry": 20, 10 | "confidenceLevel": 0.95, 11 | "ratioStableCriterion": 0.95, 12 | "nStableCriterion": 10, 13 | "mode": "predict" 14 | } 15 | -------------------------------------------------------------------------------- /JMixtComp/data/01-FunctionalCase/predict/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "z_class": { 3 | "type": "LatentClass", 4 | "paramStr": "" 5 | }, 6 | "Functional1": { 7 | "type": "Func_CS", 8 | "paramStr": "nSub: 2, nCoeff: 2" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /JMixtComp/data/02-RankCase/learn/algo.json: -------------------------------------------------------------------------------- 1 | { 2 | "nClass": 2, 3 | "nInd": 200, 4 | "nbBurnInIter": 50, 5 | "nbIter": 50, 6 | "nbGibbsBurnInIter": 50, 7 | "nbGibbsIter": 50, 8 | "nInitPerClass": 50, 9 | "nSemTry": 20, 10 | "confidenceLevel": 0.95, 11 | "ratioStableCriterion": 0.95, 12 | "nStableCriterion": 10, 13 | "mode": "learn" 14 | } 15 | -------------------------------------------------------------------------------- /JMixtComp/data/02-RankCase/learn/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "z_class": { 3 | "type": "LatentClass", 4 | "paramStr": "" 5 | }, 6 | "Rank1": { 7 | "type": "Rank_ISR", 8 | "paramStr": "" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /JMixtComp/data/02-RankCase/predict/algo.json: -------------------------------------------------------------------------------- 1 | { 2 | "nClass": 2, 3 | "nInd": 200, 4 | "nbBurnInIter": 50, 5 | "nbIter": 50, 6 | "nbGibbsBurnInIter": 50, 7 | "nbGibbsIter": 50, 8 | "nInitPerClass": 50, 9 | "nSemTry": 20, 10 | "confidenceLevel": 0.95, 11 | "ratioStableCriterion": 0.95, 12 | "nStableCriterion": 10, 13 | "mode": "predict" 14 | } 15 | -------------------------------------------------------------------------------- /JMixtComp/data/02-RankCase/predict/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "z_class": { 3 | "type": "LatentClass", 4 | "paramStr": "" 5 | }, 6 | "Rank1": { 7 | "type": "Rank_ISR", 8 | "paramStr": "" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /JMixtComp/runTest.sh: -------------------------------------------------------------------------------- 1 | build/lib/jmc data/00-SimpleCase/learn/algo.json data/00-SimpleCase/learn/data.json data/00-SimpleCase/learn/desc.json data/00-SimpleCase/learn/resLearn.json 2 | build/lib/jmc data/00-SimpleCase/predict/algo.json data/00-SimpleCase/predict/data.json data/00-SimpleCase/predict/desc.json data/00-SimpleCase/learn/resLearn.json data/00-SimpleCase/predict/resPredict.json 3 | 4 | build/lib/jmc data/01-FunctionalCase/learn/algo.json data/01-FunctionalCase/learn/data.json data/01-FunctionalCase/learn/desc.json data/01-FunctionalCase/learn/resLearn.json 5 | build/lib/jmc data/01-FunctionalCase/predict/algo.json data/01-FunctionalCase/predict/data.json data/01-FunctionalCase/predict/desc.json data/01-FunctionalCase/learn/resLearn.json data/01-FunctionalCase/predict/resPredict.json 6 | 7 | build/lib/jmc data/02-RankCase/learn/algo.json data/02-RankCase/learn/data.json data/02-RankCase/learn/desc.json data/02-RankCase/learn/resLearn.json 8 | build/lib/jmc data/02-RankCase/predict/algo.json data/02-RankCase/predict/data.json data/02-RankCase/predict/desc.json data/02-RankCase/learn/resLearn.json data/02-RankCase/predict/resPredict.json 9 | -------------------------------------------------------------------------------- /JMixtComp/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.8) 3 | 4 | project(JMixtComp) 5 | 6 | # C++ standard 7 | set(CMAKE_CXX_STANDARD 17) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | 10 | # Compile MixtComp 11 | add_subdirectory(../../MixtComp/src MixtComp) 12 | 13 | # add MixtComp's include directories and definitions 14 | include_directories(${MixtComp_INCLUDE_DIRS}) 15 | add_definitions(${MixtComp_DEFINITIONS}) 16 | 17 | 18 | # json 19 | include(CMakeLists.txt.in) 20 | include_directories(${CMAKE_BINARY_DIR}/json-src/single_include/nlohmann) # nlohmann is a header-only library 21 | 22 | 23 | # compilation flags 24 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/") 25 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) # to enable PIC on platforms that need it 26 | 27 | # add json interface code 28 | add_subdirectory(lib) 29 | 30 | # add test 31 | add_subdirectory(utest EXCLUDE_FROM_ALL) 32 | -------------------------------------------------------------------------------- /JMixtComp/src/CMakeLists.txt.in: -------------------------------------------------------------------------------- 1 | 2 | include(ExternalProject) 3 | 4 | ExternalProject_Add(json 5 | GIT_REPOSITORY https://github.com/nlohmann/json.git 6 | GIT_TAG master 7 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/json-src" 8 | BINARY_DIR "" 9 | CONFIGURE_COMMAND "" 10 | BUILD_COMMAND "" 11 | INSTALL_COMMAND "" 12 | TEST_COMMAND "" 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /JMixtComp/src/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # long file list initially generated with "find . -type f -follow -print" 2 | # with "./" prefix deleted 3 | 4 | 5 | add_library(JMixtComp 6 | JSONGraph.cpp 7 | JSONGraph.h 8 | jsonIO.h 9 | translateJSONToCPP.h 10 | translateCPPToJSON.h 11 | ) 12 | 13 | add_executable(jmc 14 | jmc.cpp 15 | ) 16 | 17 | target_link_libraries(jmc 18 | MixtComp 19 | JMixtComp 20 | ${Boost_LIBRARIES} 21 | ) 22 | -------------------------------------------------------------------------------- /JMixtComp/src/lib/jsonIO.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: Aug 6, 2018 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef JSON_JSONIO_H 24 | #define JSON_JSONIO_H 25 | 26 | #include "JSONGraph.h" 27 | #include "translateCPPToJSON.h" 28 | #include "translateJSONToCPP.h" 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /JMixtComp/src/utest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # google test project is built by MixtComp 2 | 3 | add_executable(runUtestJMC 4 | JSONGraph.cpp 5 | ) 6 | 7 | target_link_libraries(runUtestJMC 8 | gtest_main 9 | JMixtComp 10 | MixtComp 11 | ) 12 | -------------------------------------------------------------------------------- /JMixtComp/utest.sh: -------------------------------------------------------------------------------- 1 | cd build/ && make runUtestJMC && cd .. 2 | MC_DETERMINISTIC=T build/utest/runUtestJMC --gtest_output=xml:reportJMC.xml 3 | -------------------------------------------------------------------------------- /JMixtComp/valgrindRun.sh: -------------------------------------------------------------------------------- 1 | MC_DETERMINISTIC=T valgrind --xml=yes --xml-file=valgrindReportJMC.xml build/utest/runUtestJMC --gtest_output=xml:uTestReportJMC.xml 2 | -------------------------------------------------------------------------------- /LICENCE.md: -------------------------------------------------------------------------------- 1 | # Licence 2 | 3 | ## MixtComp 4 | 5 | MixtComp is distributed under the [AGPL 3.0 licence](https://www.gnu.org/licenses/agpl-3.0.en.html). It uses the following libraries: 6 | 7 | - [Eigen](http://eigen.tuxfamily.org) distributed under [MPL2 licence](https://www.mozilla.org/en-US/MPL/2.0/) 8 | - [Boost](https://www.boost.org/) distributed under [Boost licence](https://www.boost.org/users/license.html) 9 | - [CppOptimizationLibrary](https://github.com/PatWie/CppNumericalSolvers) distributed under [MIT licence](https://github.com/PatWie/CppNumericalSolvers/blob/master/LICENSE). 10 | 11 | Its JSON interface uses the [nlohmann/json library](https://github.com/nlohmann/json) under [MIT licence](https://github.com/nlohmann/json#license). 12 | 13 | MixtComp is tested using [GoogleTest](https://github.com/google/googletest/) distributed under [BSD-3 licence](https://github.com/google/googletest/blob/main/LICENSE). 14 | Code coverage is done using the [CodeCoverage](https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake) module under [Boost licence](https://github.com/bilke/cmake-modules/blob/master/LICENSE_1_0.txt). 15 | 16 | ## RMixtCompIO 17 | 18 | RMixtCompIO is distributed under the [AGPL 3.0 licence](https://www.gnu.org/licenses/agpl-3.0.en.html). It uses [Rcpp](http://www.rcpp.org/) distributed under [GPL 2.0 licence](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) and [GPL 3.0 licence](https://www.gnu.org/licenses/gpl-3.0.en.html). 19 | 20 | ## RMixtCompUtilities 21 | 22 | RMixtCompUtilities is distributed under the [AGPL 3.0 licence](https://www.gnu.org/licenses/agpl-3.0.en.html). 23 | 24 | ## RMixtComp 25 | 26 | RMixtComp is distributed under the [AGPL 3.0 licence](https://www.gnu.org/licenses/agpl-3.0.en.html). 27 | 28 | ## RJMixtComp 29 | 30 | RJMixtComp is distributed under the [AGPL 3.0 licence](https://www.gnu.org/licenses/agpl-3.0.en.html). 31 | 32 | ## RMixtCompHier 33 | 34 | RMixtCompHier is distributed under the [AGPL 3.0 licence](https://www.gnu.org/licenses/agpl-3.0.en.html). 35 | -------------------------------------------------------------------------------- /MixtComp/.clang-format: -------------------------------------------------------------------------------- 1 | # https://clang.llvm.org/docs/ClangFormatStyleOptions.html 2 | # https://llvm.org/docs/CodingStandards.html 3 | 4 | BasedOnStyle: LLVM 5 | 6 | AccessModifierOffset: -4 7 | AllowShortIfStatementsOnASingleLine: false 8 | ColumnLimit: 0 9 | FixNamespaceComments: false 10 | IndentCaseLabels: false 11 | IndentWidth: 4 12 | NamespaceIndentation: All 13 | TabWidth: 4 14 | UseTab: Always 15 | -------------------------------------------------------------------------------- /MixtComp/.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | -------------------------------------------------------------------------------- /MixtComp/archive/IO/AlgType.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: August 3, 2018 7 | * Authors: Vincent KUBICKI 8 | **/ 9 | 10 | #ifndef ALGTYPE_H 11 | #define ALGTYPE_H 12 | 13 | #include "boost/variant.hpp" 14 | #include 15 | #include "NamedAlgebra.h" 16 | 17 | namespace mixt { 18 | 19 | /** 20 | * boost::variant provides the equivalent of algebraic type. The main advantage vs polymorphism is that the syntax is lighter. The serialization graph is only used to carry the data from the depths of the model to 21 | * the IO module. Therefore using polymorphism would be overkill. 22 | * - Index 23 | * - Real 24 | * - std::string 25 | * - Matrix 26 | */ 27 | typedef typename boost::variant, NamedVector, NamedVector, NamedVector, NamedMatrix> AlgType; 28 | 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /MixtComp/archive/IO/AlgTypeVisitor.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: August 17, 2018 7 | * Authors: Vincent KUBICKI 8 | **/ 9 | 10 | #include "AlgTypeVisitor.h" 11 | 12 | #include 13 | 14 | namespace mixt { 15 | 16 | template<> 17 | Index translation(const Index& in) { 18 | return in; 19 | } 20 | 21 | template<> 22 | Index translation(const Integer& in) { 23 | return in; 24 | } 25 | 26 | template<> 27 | Real translation(const Index& in) { 28 | return in; 29 | } 30 | 31 | template<> 32 | Real translation(const Real& in) { 33 | return in; 34 | } 35 | 36 | template<> 37 | std::string translation(const std::string& in) { 38 | return in; 39 | } 40 | 41 | template<> 42 | std::vector translation, std::vector>(const std::vector& in) { 43 | return in; 44 | } 45 | 46 | template<> 47 | NamedVector translation, NamedVector>(const NamedVector& in) { 48 | return in; 49 | } 50 | 51 | template<> 52 | NamedVector translation, NamedVector>(const NamedVector& in) { 53 | return in; 54 | } 55 | 56 | template<> 57 | NamedVector translation, NamedVector>(const NamedVector& in) { 58 | return in; 59 | } 60 | 61 | template<> 62 | NamedMatrix translation, NamedMatrix>(const NamedMatrix& in) { 63 | return in; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /MixtComp/archive/IO/SGraph.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: November 14, 2014 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #include "SGraph.h" 11 | 12 | namespace mixt { 13 | 14 | void SGraph::add_payload(const std::string& name, const AlgType& data) { 15 | std::pair::iterator, bool> res = payload_.insert(std::pair(name, data)); 16 | if (!res.second) throw std::string("Try to add duplicate key ") + name; 17 | } 18 | 19 | void SGraph::add_child(const std::string& name, const SGraph& data) { 20 | std::pair::iterator, bool> res = children_.insert(std::pair(name, data)); 21 | if (!res.second) throw std::string("Try to add duplicate key ") + name; 22 | } 23 | 24 | bool SGraph::exist_payload(const std::string& name) const { 25 | std::map::const_iterator it = payload_.find(name); 26 | return it != payload_.end(); 27 | } 28 | 29 | bool SGraph::exist_child(const std::string& name) const { 30 | std::map::const_iterator it = children_.find(name); 31 | return it != children_.end(); 32 | } 33 | 34 | void SGraph::listElements() const { 35 | std::cout << "payload:" << std::endl; 36 | for (std::map::const_iterator it = payload_.begin(), itEnd = payload_.end(); it != itEnd; ++it) { 37 | std::cout << "\t" << it->first << std::endl; 38 | } 39 | 40 | std::cout << "children:" << std::endl; 41 | for (std::map::const_iterator it = children_.begin(), itEnd = children_.end(); it != itEnd; ++it) { 42 | std::cout << "\t" << it->first << std::endl; 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /MixtComp/archive/JSONToSGraph.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: August 7, 2018 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #include "gtest/gtest.h" 11 | #include "mixt_MixtComp.h" 12 | #include "jsonIO.h" 13 | 14 | using namespace mixt; 15 | 16 | TEST(JSONToSGraph, basic) { 17 | nlohmann::json expectedJSON = R"({"paramStr":"A parameter","varA":{"A nested real":12.0,"A nested string":"Hello World !"}})"_json; 18 | 19 | nlohmann::json computedJSON = SGraphToJSON(JSONToSGraph(expectedJSON)); 20 | 21 | ASSERT_EQ(expectedJSON, computedJSON); 22 | } 23 | 24 | TEST(JSONToSGraph, VectorReal) { 25 | nlohmann::json expectedJSON = R"-({"A named vector":{"ctype":"Vector","data":[1.0,2.0,3.0],"dtype":"Real","nrow":3,"rowNames":["riri","fifi","loulou"]}})-"_json; 26 | 27 | nlohmann::json computedJSON = SGraphToJSON(JSONToSGraph(expectedJSON)); 28 | 29 | ASSERT_EQ(expectedJSON, computedJSON); 30 | } 31 | 32 | TEST(JSONToSGraph, MatrixReal) { 33 | nlohmann::json expectedJSON = 34 | R"-({"A named matrix":{"colNames":["1","2","3"],"ctype":"Matrix","data":[[1.0,2.0,3.0],[4.0,5.0,6.0],[7.0,8.0,9.0]],"dtype":"Real","ncol":3,"nrow":3,"rowNames":["A","B","C"]}})-"_json; 35 | 36 | nlohmann::json computedJSON = SGraphToJSON(JSONToSGraph(expectedJSON)); 37 | 38 | ASSERT_EQ(expectedJSON, computedJSON); 39 | } 40 | 41 | TEST(JSONToSGraph, VectorOfString) { 42 | nlohmann::json expectedJSON = R"-({"var1":["12.0","-35.90","205.72"]})-"_json; 43 | 44 | nlohmann::json computedJSON = SGraphToJSON(JSONToSGraph(expectedJSON)); 45 | 46 | ASSERT_EQ(expectedJSON, computedJSON); 47 | } 48 | -------------------------------------------------------------------------------- /MixtComp/archive/Makevars: -------------------------------------------------------------------------------- 1 | # flags to be used when MixtComp is not built through R 2 | 3 | # CXXFLAGS = -O0 -g -DMC_DEBUG_NEW -Wall -mtune=core2 4 | # CXXFLAGS = -O3 -DMC_DEBUG_NEW -Wall -mtune=core2 5 | 6 | # CXX = g++ -m64 7 | 8 | CXX = g++ 9 | # CXX = clang++ 10 | CXXFLAGS = -O2 -g -Wall -DMC_VERBOSE -DMC_TIMERVERBOSE -------------------------------------------------------------------------------- /MixtComp/archive/json/AlgTypeVisJSON.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: Aug 6, 2018 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #ifndef JSON_ALGTYPEVISJSON_H 11 | #define JSON_ALGTYPEVISJSON_H 12 | 13 | #include "json.hpp" 14 | #include "boost/variant.hpp" 15 | 16 | #include 17 | 18 | /** 19 | * Visitor for boost::variant, to perform the correct operation on every payload element in a SGraph 20 | */ 21 | namespace mixt { 22 | 23 | class AlgTypeVisJSON: public boost::static_visitor<> { 24 | public: 25 | AlgTypeVisJSON(nlohmann::json& j, const std::string& payloadName); 26 | 27 | void operator()(Index i) const; 28 | 29 | void operator()(Integer i) const; 30 | 31 | void operator()(const Real r) const; 32 | 33 | void operator()(const std::string& str) const; 34 | 35 | void operator()(const std::vector& vec) const; 36 | 37 | void operator()(const NamedVector& vec) const; 38 | 39 | void operator()(const NamedVector& vec) const; 40 | 41 | void operator()(const NamedVector& vec) const; 42 | 43 | void operator()(const NamedMatrix& mat) const; 44 | 45 | private: 46 | nlohmann::json& j_; 47 | const std::string& payloadName_; 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /MixtComp/archive/json/JSONToSGraph.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: Aug 3, 2018 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #ifndef JSONTOSGRAPH_H 11 | #define JSONTOSGRAPH_H 12 | 13 | #include "json.hpp" 14 | 15 | #include 16 | 17 | namespace mixt { 18 | 19 | SGraph JSONToSGraph(const nlohmann::json& j); 20 | 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /MixtComp/archive/json/SGraphToJSON.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: Aug 3, 2018 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #ifndef SGRAPHTOJSON_H 11 | #define SGRAPHTOJSON_H 12 | 13 | #include "json.hpp" 14 | 15 | #include 16 | 17 | namespace mixt { 18 | 19 | /** 20 | * nlohmann::json is recursive, and mixt::SGraph is recursive too. Translation should be easy. 21 | */ 22 | nlohmann::json SGraphToJSON(const SGraph& graph); 23 | 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /MixtComp/build.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build 2 | cd build 3 | if [ $# -eq 0 ] 4 | then 5 | cmake -DCMAKE_BUILD_TYPE=Debug ../src 6 | else 7 | cmake -DCMAKE_BUILD_TYPE=$1 ../src 8 | fi 9 | cmake --build . -------------------------------------------------------------------------------- /MixtComp/clean.sh: -------------------------------------------------------------------------------- 1 | find build ! -name 'empty' -type f -exec rm -f {} + 2 | find build ! -name '.' -type d -exec rm -r -f {} + -------------------------------------------------------------------------------- /MixtComp/compile_commands.json: -------------------------------------------------------------------------------- 1 | build/compile_commands.json -------------------------------------------------------------------------------- /MixtComp/docs/article/BigStat.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/article/BigStat.pdf -------------------------------------------------------------------------------- /MixtComp/docs/article/SEM.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/article/SEM.pdf -------------------------------------------------------------------------------- /MixtComp/docs/article/discriminativeLevelAndSimilarity.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/article/discriminativeLevelAndSimilarity.pdf -------------------------------------------------------------------------------- /MixtComp/docs/article/functionalModel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/article/functionalModel.pdf -------------------------------------------------------------------------------- /MixtComp/docs/article/massiccc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/article/massiccc.pdf -------------------------------------------------------------------------------- /MixtComp/docs/article/ordinalModel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/article/ordinalModel.pdf -------------------------------------------------------------------------------- /MixtComp/docs/article/rankModel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/article/rankModel.pdf -------------------------------------------------------------------------------- /MixtComp/docs/article/similarityClass.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/article/similarityClass.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/140101 - proposal/ProjectSpecifications.txt: -------------------------------------------------------------------------------- 1 | This file contains all the necessary specifications like naming conventions and include patterns. 2 | 3 | 4 | -------------------------------------------------------------------------------- /MixtComp/docs/dev/140101 - proposal/Proposal.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/140101 - proposal/Proposal.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/140101 - proposal/SoftwareDesign/architecture.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/140101 - proposal/SoftwareDesign/architecture.dia -------------------------------------------------------------------------------- /MixtComp/docs/dev/140101 - proposal/SoftwareDesign/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/140101 - proposal/SoftwareDesign/architecture.png -------------------------------------------------------------------------------- /MixtComp/docs/dev/140101 - proposal/StatisticalDocumentation/DiagonalMixtures.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/140101 - proposal/StatisticalDocumentation/DiagonalMixtures.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/140101 - proposal/frameworkspecification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/140101 - proposal/frameworkspecification.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/150817 - ProgrammersGuide/doc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/150817 - ProgrammersGuide/doc.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/170616 - mise à jour majeure/1 - feuille de route.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/170616 - mise à jour majeure/1 - feuille de route.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/170616 - mise à jour majeure/2 - avancement modifications.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/170616 - mise à jour majeure/2 - avancement modifications.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/170616 - mise à jour majeure/3 - tests intermédiaires.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/170616 - mise à jour majeure/3 - tests intermédiaires.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/170616 - mise à jour majeure/4 - probabilités observées.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/170616 - mise à jour majeure/4 - probabilités observées.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/170616 - mise à jour majeure/5 - présentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/170616 - mise à jour majeure/5 - présentation.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/170616 - mise à jour majeure/6 - documentation scientifique.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/170616 - mise à jour majeure/6 - documentation scientifique.pdf -------------------------------------------------------------------------------- /MixtComp/docs/dev/180308 - Initialization/recap.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/MixtComp/docs/dev/180308 - Initialization/recap.ods -------------------------------------------------------------------------------- /MixtComp/docs/developmentEnvironment.md: -------------------------------------------------------------------------------- 1 | # Development environment 2 | 3 | ## Current 4 | 5 | VS Code with the the following extensions: 6 | 7 | - clangd 8 | - Disable Intellisense from Microsoft C++ extension. The formatting should be automatically handled upon detection of the `.clang-format` file at the root of the project. 9 | - markdownlint 10 | 11 | Enable the "Format on save" option to ensure everything is properly formatted. 12 | 13 | ## Previous 14 | 15 | The general style used is K&R from Eclipse, modified for a line wrap at 200 characters. 16 | -------------------------------------------------------------------------------- /MixtComp/docs/howToAddModelInR.md: -------------------------------------------------------------------------------- 1 | # Add a model in the different R packages 2 | 3 | Once you have add a model in C++ (check [Statistical model description](./howToAddModel.md)), some functions in different R packages need to be updated to use it. 4 | 5 | ## Documentation to update 6 | 7 | First of all, add the model in the following documentation: 8 | 9 | * [main README](../../README.md) 10 | * [Data format](./dataFormat.md) 11 | * [Output object](./objectOutput.md) 12 | 13 | ## RMixtComp 14 | 15 | Update the documentation in the [mixtCompLearn function](../../RMixtComp/R/MIXTCOMP_mixtCompLearn.R). 16 | 17 | Add the new model in the [getParam function](../../RMixtCompUtilities/R/MIXTCOMP_getParam.R). The function returns a matrix where rows correspond to classes and columns to the estimated parameters. 18 | 19 | Add the new model in the [availableModels function](../../RMixtCompUtilities/R/MIXTCOMP_misc.R). The function returns a data.frame containing all the models and some information (missing data format, hyperparameters...). 20 | 21 | If the model requires some hyperparameters and you want to provide default values, you can add them in the [completeModel function](../../RMixtCompUtilities/R/MIXTCOMP_formatData.R). 22 | 23 | Update [plotDataCI function](../../RMixtCompUtilities/R/PLOT_plotUnivariateDistributions.R) with the new model. It requires to add an [extractCI** function](../../RMixtCompUtilities/R/PLOT_extractCIbounds.R) that compute the theoretical mean and the confidence interval per class. 24 | 25 | Update [plotDataBoxplot function](../../RMixtCompUtilities/R/PLOT_plotUnivariateBoxplots.R) with the new model. It plots a boxplot of the data per class. 26 | 27 | Update [plotParamConvergence function](../../RMixtCompUtilities/R/PLOT_plotConvergence.R) with the new model. It plots the evolution of the estimated parameters during the algorithm's run. 28 | -------------------------------------------------------------------------------- /MixtComp/docs/math.md: -------------------------------------------------------------------------------- 1 | # Mathematical background of some elements of MixtComp 2 | 3 | ## Initialization of latent and Unobserved variables in initializeLatent() 4 | 5 | The joint distribution of the data $`x`$ and $`w`$ can be used to initialize a latent or unobserved variables (say $`w_i^j`$) of the $`i`$-th individual for the $`j`$-th variable using current estimated parameters. This distribution is: 6 | 7 | ```math 8 | p(w_i^j, x_i^j) = \sum_{k} p(w_i^j, x_i^j | z = k) * p(z = k) 9 | ``` 10 | 11 | Sampling according to this law can be done by: 12 | 13 | 1. Sampling the class $`k`$ according to a multinomial with the current proportion $`(p(z = j))_{j=1,...,K}`$ as probabilities 14 | 2. Sampling $`w_i^j`$ according to $`p(w_i^j, x_i^j | z = k)`$ 15 | 16 | The first step is done by calling `sampleZProportion()` and the second by calling `sampleUnobservedAndLatent()`. 17 | `sampleZProportion()` first assigns proportion to each row of `tik_` and then calls `sampleZ()`. 18 | -------------------------------------------------------------------------------- /MixtComp/src/CMakeLists.txt.in: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | ExternalProject_Add(optim 4 | GIT_REPOSITORY https://github.com/modal-inria/CppNumericalSolvers.git 5 | GIT_TAG master 6 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/optim-src" 7 | BINARY_DIR "" 8 | CONFIGURE_COMMAND "" 9 | BUILD_COMMAND "" 10 | INSTALL_COMMAND "" 11 | TEST_COMMAND "" 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /MixtComp/src/archive/IO/UTestAlgTypeVisitor.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: August 17, 2018 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #include "gtest/gtest.h" 11 | #include "MixtComp.h" 12 | 13 | using namespace mixt; 14 | 15 | TEST(AlgTypeVisitor, BasicTest) { 16 | Index in = 12; 17 | 18 | AlgType obj; 19 | obj = in; 20 | 21 | Real res; 22 | 23 | res = boost::apply_visitor(AlgTypeVisitor(), obj); 24 | 25 | ASSERT_NEAR(Real(in), res, epsilon); 26 | } 27 | -------------------------------------------------------------------------------- /MixtComp/src/archive/IO/UTestSGraph.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: August 3, 2018 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #include "gtest/gtest.h" 11 | #include "MixtComp.h" 12 | 13 | using namespace mixt; 14 | 15 | /** Get to get value. */ 16 | TEST(SGraph, BasicIOGet) { 17 | SGraph test; 18 | 19 | std::string name = "Quote"; 20 | Real val = 12.0; 21 | 22 | test.add_payload(name, val); 23 | 24 | Real res = test.get_payload(name); 25 | 26 | ASSERT_NEAR(val, res, epsilon); 27 | } 28 | -------------------------------------------------------------------------------- /MixtComp/src/archive/SGraphToJSON.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: Aug 3, 2018 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "json.hpp" 15 | 16 | #include "JSONToSGraph.h" 17 | 18 | namespace mixt { 19 | 20 | nlohmann::json SGraphToJSON(const SGraph& graph) { 21 | nlohmann::json res; 22 | 23 | const std::map& payload = graph.get_payload(); 24 | for (std::map::const_iterator it = payload.begin(), 25 | itEnd = payload.end(); it != itEnd; ++it) { 26 | const std::pair& val = *it; 27 | 28 | boost::apply_visitor(AlgTypeVisJSON(res, val.first), val.second); 29 | } 30 | 31 | const std::map& children = graph.get_children(); 32 | for (std::map::const_iterator it = children.begin(), 33 | itEnd = children.end(); it != itEnd; ++it) { 34 | const std::pair& val = *it; 35 | res[val.first] = SGraphToJSON(val.second); 36 | } 37 | 38 | return res; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /MixtComp/src/archive/model Ordinal/mixt_BOSNode.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: April 29, 2015 7 | * Authors: Vincent KUBICKI 8 | **/ 9 | 10 | #ifndef MIXT_BOSNODE 11 | #define MIXT_BOSNODE 12 | 13 | #include 14 | 15 | namespace mixt { 16 | 17 | /** 18 | * Structure containing the values of an iteration of the BOS algorithm. 19 | * A node contains information on: 20 | * - breaking point y 21 | * - blindness of comparison z 22 | * - final segment e 23 | */ 24 | class BOSNode { 25 | public: 26 | int y_; // breaking point 27 | Vector > part_; // partition is uniquely defined by e_ from previous iteration and by y_ 28 | int partSize_; // number of elements in the partition 29 | int z_; // blindness of comparison 30 | Vector e_; // final segment for current iteration, as an index of the partition 31 | 32 | /** 33 | * Compute the probability of a given segment conditionally to the partition and y of the node 34 | * 35 | * @param mu localization parameter (mode) of the distribution 36 | * @param pi precision parameter of the distribution 37 | * @param seg external segment 38 | */ 39 | void partition(const Vector& e); 40 | 41 | /** 42 | * Check if a segment is a member of the partition 43 | * 44 | * @param e segment which presence should be checked 45 | */ 46 | bool isInPart(const Vector& e) const; 47 | 48 | Real yLogProba(const Vector& e) const; 49 | Real zLogProba(Real pi) const; 50 | 51 | /** 52 | * Compute the probability of the current segment conditionally to the partition and y of the node 53 | * 54 | * @param mu localization parameter (mode) of the distribution 55 | * @param pi precision parameter of the distribution 56 | */ 57 | Real eLogProba(int mu, Real pi) const; 58 | }; 59 | 60 | } // namespace mixt 61 | 62 | #endif // MIXT_BOSNODE 63 | -------------------------------------------------------------------------------- /MixtComp/src/archive/utest Ordinal/UTestBOSNode.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 2.0 - 13 march 2017 2 | * Copyright (C) Inria - Lille 1 */ 3 | 4 | /* 5 | * Project: MixtComp 6 | * Created on: March 24, 2015 7 | * Author: Vincent KUBICKI 8 | **/ 9 | 10 | #include "../UTest.h" 11 | 12 | using namespace mixt; 13 | 14 | /** 15 | * Computation of a partition 16 | */ 17 | TEST(BOSNode, partition0) { 18 | Vector e; 19 | e << 0, 5; 20 | BOSNode node; 21 | node.y_ = 2; 22 | Vector > partExpected(3); 23 | partExpected(0) << 0, 1; 24 | partExpected(1) << 2, 2; 25 | partExpected(2) << 3, 5; 26 | 27 | node.partition(e); 28 | ASSERT_EQ(node.part_, partExpected); // has the real mode been estimated correctly ? 29 | } 30 | 31 | /** 32 | * Computation of a partition 33 | */ 34 | TEST(BOSNode, partition1) { 35 | Vector e; 36 | e << 6, 8; 37 | BOSNode node; 38 | node.y_ = 2; 39 | Vector > partExpected(0); 40 | 41 | node.partition(e); 42 | ASSERT_EQ(node.part_, partExpected); // has the real mode been estimated correctly ? 43 | } 44 | 45 | /** 46 | * Computation of a partition 47 | */ 48 | TEST(BOSNode, partition2) { 49 | Vector e; 50 | e << 6, 8; 51 | BOSNode node; 52 | node.y_ = 6; 53 | Vector > partExpected(2); 54 | partExpected(0) << 6, 6; 55 | partExpected(1) << 7, 8; 56 | 57 | node.partition(e); 58 | ASSERT_EQ(node.part_, partExpected); // has the real mode been estimated correctly ? 59 | } 60 | 61 | /** 62 | * Computation of a partition 63 | */ 64 | TEST(BOSNode, partition3) { 65 | Vector e; 66 | e << 6, 8; 67 | BOSNode node; 68 | node.y_ = 8; 69 | Vector > partExpected(2); 70 | partExpected(0) << 6, 7; 71 | partExpected(1) << 8, 8; 72 | 73 | node.partition(e); 74 | ASSERT_EQ(node.part_, partExpected); // has the real mode been estimated correctly ? 75 | } 76 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Composer/ClassDataStat.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: May 29, 2015 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef LIB_COMPOSER_CLASSDATASTAT_H 24 | #define LIB_COMPOSER_CLASSDATASTAT_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace mixt { 31 | 32 | class ClassDataStat { 33 | public: 34 | ClassDataStat(ZClassInd& zClassInd); 35 | 36 | void setNbIndividual(int nbInd); 37 | 38 | void sampleVals(int sample, int iteration, int iterationMax); 39 | 40 | void imputeData(int ind, Matrix& tik); 41 | 42 | const Matrix& getDataStatStorage() const { 43 | return dataStatStorage_; 44 | } 45 | 46 | private: 47 | /** Reference to augmented data */ 48 | ZClassInd& zClassInd_; 49 | 50 | /** Dense description of the missing values */ 51 | Matrix dataStatStorage_; 52 | 53 | void sample(int ind); 54 | }; 55 | 56 | } // namespace mixt 57 | 58 | #endif // CLASSDATASTAT_H 59 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Composer/ClassSampler.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: May 4, 2015 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef LIB_COMPOSER_CLASSSAMPLER_H 24 | #define LIB_COMPOSER_CLASSSAMPLER_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace mixt 32 | { 33 | 34 | class MixtureComposer; 35 | 36 | class ClassSampler 37 | { 38 | public: 39 | ClassSampler(ZClassInd& ZClassInd, 40 | const Matrix& tik, 41 | int nbClass); 42 | 43 | /** 44 | * Sample new values for the missing variables of the given individual. Do not uses MixtureComposer::checkSampleCondition 45 | * to speed-up the sampling process. Used during rejection sampling. 46 | * @param i individual for which z must be sampled 47 | * */ 48 | void sStepNoCheck(int i); 49 | private: 50 | int nbClass_; 51 | 52 | ZClassInd& zClassInd_; 53 | 54 | const Matrix& tik_; 55 | 56 | MultinomialStatistic multi_; 57 | }; 58 | 59 | } // namespace mixt 60 | 61 | #endif /* CLASSSAMPLER_H */ 62 | -------------------------------------------------------------------------------- /MixtComp/src/lib/IO/IOFunctions.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: Aug 9, 2018 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include "IOFunctions.h" 24 | 25 | namespace mixt { 26 | 27 | void quantileNames(Index ncol, Real confidenceLevel, std::vector& colNames) { 28 | Real alpha = (1. - confidenceLevel) / 2.; 29 | 30 | if (ncol == 1) { // predict 31 | colNames.resize(1); 32 | colNames[0] = "value"; 33 | } else { // learn 34 | colNames.resize(3); 35 | colNames[0] = "median"; 36 | colNames[1] = std::string("q ") + std::to_string((alpha * 100.)) + "%"; 37 | colNames[2] = std::string("q ") + std::to_string(((1. - alpha) * 100.)) + "%"; 38 | } 39 | } 40 | 41 | void completePath(const std::vector& path, const std::string& name, std::string& str) { 42 | str = ""; 43 | for (std::vector::const_iterator it = path.begin(), itEnd = path.end(); it != itEnd; ++it) { 44 | str += "/" + *it; 45 | } 46 | str += "/" + name; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /MixtComp/src/lib/IO/SpecialStr.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 25, 2014 20 | * Authors: Vincent KUBICKI , 21 | **/ 22 | 23 | #include 24 | 25 | namespace mixt { 26 | 27 | const std::string strNumber = "((?:(?:-|\\+)?(?:\\d+(?:\\.\\d*)?)|(?:\\.\\d+))(?:(?:e|E)-\\d+)?)"; // note the multiple non-capturing groups, as only the overall group is capturing 28 | const std::string strPositiveInteger = "(\\d+)"; 29 | const std::string strQMark = "(\\?)"; 30 | const std::string strBlank = " *"; 31 | const std::string strLeftPar = " *\\[ *"; 32 | const std::string strRightPar = " *\\] *"; 33 | const std::string strCentralColon = " *: *"; 34 | const std::string strMinusInf = "-inf"; 35 | const std::string strPlusInf = "\\+inf"; 36 | 37 | } // namespace mixt 38 | -------------------------------------------------------------------------------- /MixtComp/src/lib/IO/SpecialStr.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 25, 2014 20 | * Authors: Vincent KUBICKI , 21 | **/ 22 | 23 | #ifndef LIB_IO_SPECIALSTR 24 | #define LIB_IO_SPECIALSTR 25 | 26 | #include 27 | 28 | namespace mixt { 29 | 30 | extern const std::string strNumber; 31 | extern const std::string strPositiveInteger; 32 | extern const std::string strQMark; 33 | extern const std::string strBlank; 34 | extern const std::string strLeftPar; 35 | extern const std::string strRightPar; 36 | extern const std::string strCentralColon; 37 | extern const std::string strMinusInf; 38 | extern const std::string strPlusInf; 39 | 40 | } // namespace mixt 41 | 42 | #endif // SPECIALSTR 43 | -------------------------------------------------------------------------------- /MixtComp/src/lib/LinAlg/Typedef.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 7, 2018 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #include 24 | 25 | namespace mixt { 26 | 27 | Real toReal(const std::string& s) { 28 | return std::stod(s); 29 | } 30 | 31 | Index toIndex(const std::string& s) { 32 | return std::stol(s); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /MixtComp/src/lib/LinAlg/Typedef.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: February 24, 2016 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef TYPEDEF_H 24 | #define TYPEDEF_H 25 | 26 | #include 27 | #include 28 | 29 | namespace mixt { 30 | 31 | /** Eigen storage is column-major by default, which suits the main way of accessing data, 32 | * by looping over individuals instead of variables */ 33 | typedef double Real; 34 | // typedef std::size_t Index; 35 | // typedef int Index; 36 | typedef unsigned long Index; 37 | 38 | typedef long Integer; 39 | 40 | Real toReal(const std::string& s); 41 | 42 | Index toIndex(const std::string& s); 43 | 44 | } 45 | 46 | #endif // TYPEDEF_H 47 | -------------------------------------------------------------------------------- /MixtComp/src/lib/LinAlg/names.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 21, 2018 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #include 24 | #include 25 | #include "names.h" 26 | 27 | namespace mixt { 28 | 29 | const std::string names::name = "Index"; 30 | 31 | const std::string names::name = "Integer"; 32 | 33 | const std::string names::name = "Integer"; 34 | 35 | const std::string names::name = "Real"; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /MixtComp/src/lib/LinAlg/names.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 21, 2018 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef JSON_NAMES 24 | #define JSON_NAMES 25 | 26 | #include 27 | #include 28 | 29 | namespace mixt { 30 | 31 | template 32 | class names {}; 33 | 34 | template<> 35 | class names { 36 | public: 37 | static const std::string name; 38 | }; 39 | 40 | template<> 41 | class names { 42 | public: 43 | static const std::string name; 44 | }; 45 | 46 | template<> 47 | class names { 48 | public: 49 | static const std::string name; 50 | }; 51 | 52 | template<> 53 | class names { 54 | public: 55 | static const std::string name; 56 | }; 57 | 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /MixtComp/src/lib/MixtComp.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: Apr 14, 2014 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef MIXTCOMP_H 24 | #define MIXTCOMP_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | #endif /* MIXTCOMP_H */ 54 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Mixture/Functional/FunctionCSParser.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: June 20, 2016 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef FUNCTIONCSPARSER 24 | #define FUNCTIONCSPARSER 25 | 26 | #include 27 | #include 28 | 29 | namespace mixt { 30 | 31 | std::string parseFunctionalStr(Index nSub, Index nCoeff, const std::vector& dataStr, Vector& vecInd); 32 | 33 | } // namespace mixt 34 | 35 | #endif // FUNCTIONCSPARSER 36 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Mixture/Rank/RankISRParser.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: September 28, 2015 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef LIB_MIXTURE_RANK_RANKISRPARSER_H 24 | #define LIB_MIXTURE_RANK_RANKISRPARSER_H 25 | 26 | #include 27 | #include 28 | 29 | namespace mixt { 30 | 31 | std::string parseRankStr(const std::vector& vecStr, int minMod, int& nbMod, Vector& vecInd); 32 | 33 | } // namespace mixt 34 | 35 | #endif // RANKISRPARSER_H 36 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Mixture/Simple/Gaussian/GaussianSampler.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: 14 feb. 2014 20 | * Authors: Vincent KUBICKI 21 | * Serge IOVLEFF 22 | **/ 23 | 24 | #ifndef GAUSSIANSAMPLER_H 25 | #define GAUSSIANSAMPLER_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | 32 | namespace mixt 33 | { 34 | 35 | class GaussianSampler 36 | { 37 | public: 38 | GaussianSampler(AugmentedData >& augData, 39 | const Vector& param, 40 | int nbClass); 41 | 42 | void samplingStepNoCheck(int i, 43 | int z_i); 44 | private: 45 | AugmentedData >& augData_; 46 | 47 | const Vector& param_; 48 | 49 | UniformStatistic uniform_; 50 | 51 | GaussianStatistic normal_; 52 | 53 | ExponentialStatistic exponential_; 54 | }; 55 | 56 | } // namespace mixt 57 | 58 | #endif /* GAUSSIANSAMPLER_H */ 59 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Mixture/Simple/Multinomial/MultinomialSampler.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: Mar 27, 2014 20 | * Authors: Vincent KUBICKI 21 | * Serge IOVLEFF 22 | **/ 23 | 24 | #ifndef MULTINOMIALSAMPLER_H 25 | #define MULTINOMIALSAMPLER_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace mixt 32 | { 33 | 34 | class MultinomialSampler 35 | { 36 | public: 37 | MultinomialSampler(AugmentedData >& augData, 38 | const Vector& param, 39 | int nbClass); 40 | 41 | /** 42 | * Sample an individual according to a given class 43 | * @param i individual for which z must be sampled 44 | * @param z_i individual's class 45 | */ 46 | void samplingStepNoCheck(int i, int z_i); 47 | 48 | private: 49 | int nbClass_; 50 | 51 | AugmentedData >& augData_; 52 | 53 | const Vector& param_; 54 | 55 | MultinomialStatistic multi_; 56 | }; 57 | 58 | } // namespace mixt 59 | 60 | #endif /* MULTINOMIALSAMPLER_H */ 61 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Mixture/Simple/NegativeBinomial/NegativeBinomialSampler.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: July 19, 2018 20 | * Authors: Quentin GRIMONPREZ 21 | **/ 22 | 23 | #ifndef NEGATIVEBINOMIALSAMPLER_H 24 | #define NEGATIVEBINOMIALSAMPLER_H 25 | 26 | #include 27 | #include 28 | #include "NegativeBinomialStatistic.h" 29 | 30 | namespace mixt 31 | { 32 | 33 | class IMixture; 34 | 35 | class NegativeBinomialSampler 36 | { 37 | public: 38 | NegativeBinomialSampler(AugmentedData >& augData, 39 | const Vector& param, int nbClass); 40 | 41 | void samplingStepNoCheck(int i, 42 | int z_i); 43 | private: 44 | AugmentedData >& augData_; 45 | 46 | const Vector& param_; 47 | 48 | /** Statistic object to describe Negative Binomial law */ 49 | NegativeBinomialStatistic negativeBinomial_; 50 | }; 51 | 52 | } // namespace mixt 53 | 54 | #endif // NEGATIVEBINOMIALSAMPLER_H 55 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Mixture/Simple/Poisson/PoissonSampler.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: December 12, 2014 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef POISSONSAMPLER_H 24 | #define POISSONSAMPLER_H 25 | 26 | #include 27 | #include 28 | #include "PoissonStatistic.h" 29 | 30 | namespace mixt 31 | { 32 | 33 | class IMixture; 34 | 35 | class PoissonSampler 36 | { 37 | public: 38 | PoissonSampler(AugmentedData >& augData, 39 | const Vector& param, 40 | int nbClass); 41 | 42 | void samplingStepNoCheck(int i, 43 | int z_i); 44 | private: 45 | AugmentedData >& augData_; 46 | 47 | const Vector& param_; 48 | 49 | /** Statistic object to describe Poisson law */ 50 | PoissonStatistic poisson_; 51 | }; 52 | 53 | } // namespace mixt 54 | 55 | #endif // POISSONSAMPLER_H 56 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Mixture/Simple/Weibull/WeibullSampler.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: December 12, 2014 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef WEIBULLSAMPLER_H 24 | #define WEIBULLSAMPLER_H 25 | 26 | #include 27 | #include 28 | #include "WeibullStatistic.h" 29 | 30 | namespace mixt { 31 | 32 | class WeibullSampler { 33 | public: 34 | WeibullSampler(AugmentedData >& augData, const Vector& param, Index nbClass); 35 | 36 | void samplingStepNoCheck(Index i, Index z_i); 37 | private: 38 | AugmentedData >& augData_; 39 | 40 | const Vector& param_; 41 | 42 | WeibullStatistic weibull_; 43 | }; 44 | 45 | } // namespace mixt 46 | 47 | #endif // WEIBULLSAMPLER_H 48 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Statistic/ExponentialStatistic.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: December 16, 2014 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef EXPONENTIALSTATISTIC_H 24 | #define EXPONENTIALSTATISTIC_H 25 | 26 | #include 27 | #include 28 | 29 | namespace mixt 30 | { 31 | 32 | class ExponentialStatistic 33 | { 34 | public: 35 | ExponentialStatistic(); 36 | 37 | /** cdf evaluated at individual x */ 38 | Real cdf(Real x, 39 | Real lambda) const; 40 | 41 | /** pdf evaluated at individual x */ 42 | Real pdf(Real x, 43 | Real lambda) const; 44 | 45 | /** Sample a value from an Exponential law with rate lambda */ 46 | Real sample(Real lambda); 47 | private: 48 | /** Random number generator */ 49 | boost::random::mt19937 rng_; 50 | }; 51 | 52 | } // namespace mixt 53 | 54 | #endif // EXPONENTIALSTATISTIC_H 55 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Statistic/Functions.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: January 23rd, 2018 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef FUNCTIONS_H 24 | #define FUNCTIONS_H 25 | 26 | #include 27 | 28 | namespace mixt { 29 | 30 | /** 31 | * Empiric computation of a quantile, given observed data. 32 | */ 33 | template 34 | A quantile(const Vector& v, Real p) { 35 | Vector sorted = v; // copy is necessary as sort is applied on mutable vector 36 | sorted.sort(); 37 | Index cutPoint = p * v.size(); 38 | return sorted(cutPoint); 39 | } 40 | 41 | /** 42 | * Empiric computation of cdf, given observed data. 43 | */ 44 | template 45 | Real cdf(const Vector& v, Real a) { 46 | Vector sorted = v; // copy is necessary as sort is applied on mutable vector 47 | sorted.sort(); 48 | Index size = v.size(); 49 | 50 | Index i = 0; 51 | for (; i < size; ++i) { 52 | if (a <= sorted(i)) 53 | break; 54 | } 55 | 56 | return Real(i) / Real(size - 1); 57 | } 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Statistic/MultinomialStatistic.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: April 24, 2015 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include 24 | #include "MultinomialStatistic.h" 25 | 26 | namespace mixt { 27 | 28 | int MultinomialStatistic::sampleInt(int low, int high) { 29 | std::uniform_int_distribution uni_(low, high); 30 | int x = uni_(rng_); 31 | return x; 32 | } 33 | 34 | } // namespace mixt 35 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Statistic/RNG.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: June 29, 2017 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | namespace mixt { 30 | 31 | bool deterministicMode() { 32 | static const char *str_ptr = std::getenv(deterministicEnvVar); 33 | static bool detMode = (str_ptr == NULL) ? (false) : (true); 34 | return detMode; 35 | } 36 | 37 | int deterministicInitialSeed() { 38 | const char *str_ptr = std::getenv(deterministicEnvVar); 39 | 40 | if (str_ptr == NULL) { 41 | return 0; 42 | } else { 43 | int seed = std::atoi(str_ptr); 44 | #ifdef MC_VERBOSE 45 | std::cout << "Initial random seed value: " << seed << std::endl; 46 | #endif 47 | return seed; 48 | } 49 | } 50 | 51 | } // namespace mixt 52 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Statistic/RNG.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: June 29, 2017 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef RNG_H 24 | #define RNG_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | namespace mixt { 32 | 33 | bool deterministicMode(); 34 | 35 | int deterministicInitialSeed(); 36 | 37 | template 38 | std::size_t seed(const T* const p_caller) { 39 | static Index nCall = deterministicInitialSeed(); 40 | 41 | if (deterministicMode() == false) { 42 | return size_t(p_caller) + time(0); 43 | } else { 44 | ++nCall; 45 | // std::cout << "seed, nCall: " << nCall << std::endl; 46 | return nCall; 47 | } 48 | } 49 | 50 | } // namespace mixt 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Statistic/Statistic.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 20, 2014 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef STATISTIC_H 24 | #define STATISTIC_H 25 | 26 | #include 27 | #include 28 | #include "Functions.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "UniformIntStatistic.h" 34 | 35 | #endif // STATISTIC_H 36 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Statistic/UniformIntStatistic.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * UniformIntStatistic.h 19 | * 20 | * Created on: 17 déc. 2018 21 | * Author: Quentin Grimonprez 22 | */ 23 | 24 | #ifndef LIB_STATISTIC_UNIFORMINTSTATISTIC_H_ 25 | #define LIB_STATISTIC_UNIFORMINTSTATISTIC_H_ 26 | 27 | 28 | #include 29 | #include 30 | 31 | namespace mixt 32 | { 33 | 34 | class UniformIntStatistic 35 | { 36 | public: 37 | UniformIntStatistic(); 38 | 39 | /** cdf evaluated at individual x */ 40 | Real cdf(int x, int min, int max) const; 41 | 42 | /** pdf evaluated at individual x */ 43 | Real pdf(int x, int min, int max) const; 44 | 45 | /** 46 | * Sample an integer from a uniform distribution 47 | * @param min lower bound of the support 48 | * @param max higher bound of the support 49 | * @return integer uniformly sampled from [low:high] 50 | */ 51 | int sample(int min, int max); 52 | 53 | private: 54 | /** Random number generator */ 55 | boost::random::mt19937 rng_; 56 | }; 57 | 58 | } // namespace mixt 59 | 60 | 61 | #endif /* LIB_STATISTIC_UNIFORMINTSTATISTIC_H_ */ 62 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Statistic/UniformStatistic.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: December 16, 2014 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef UNIFORMSTATISTIC_H 24 | #define UNIFORMSTATISTIC_H 25 | 26 | #include 27 | #include 28 | 29 | namespace mixt 30 | { 31 | 32 | class UniformStatistic 33 | { 34 | public: 35 | UniformStatistic(); 36 | 37 | /** cdf evaluated at individual x */ 38 | Real cdf(Real x, 39 | Real min, 40 | Real max) const; 41 | 42 | /** pdf evaluated at individual x */ 43 | Real pdf(Real x, 44 | Real min, 45 | Real max) const; 46 | 47 | /** 48 | * Sample a Real from a uniform distribution 49 | * @param min lower bound of the support 50 | * @param max higher bound of the support 51 | * @return Real uniformly sampled from [low:high] 52 | */ 53 | Real sample(Real min, 54 | Real max); 55 | private: 56 | /** Random number generator */ 57 | boost::random::mt19937 rng_; 58 | }; 59 | 60 | } // namespace mixt 61 | 62 | #endif // UNIFORMSTATISTIC_H 63 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Various/Enum.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: October 10, 2014 20 | * Authors: Vincent KUBICKI , 21 | **/ 22 | 23 | #ifndef ENUM_H_ 24 | #define ENUM_H_ 25 | 26 | namespace mixt { 27 | 28 | /** Do not force member values with = assignment, otherwise NB_ENUM_MISTYPE will 29 | * not contain the number of elements in MisType */ 30 | enum MisType { 31 | present_, 32 | missing_, 33 | missingFiniteValues_, 34 | missingIntervals_, 35 | missingLUIntervals_, // left unbounded interval, (-inf, a] 36 | missingRUIntervals_, // right unbounded interval, [a, +inf) 37 | nb_enum_MisType_ 38 | }; 39 | 40 | enum RunMode { 41 | learning_, 42 | prediction_ 43 | }; 44 | 45 | enum RunType { 46 | burnIn_, 47 | run_, 48 | }; 49 | 50 | } // namespace mixt 51 | 52 | #endif /* ENUM_H_ */ 53 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Various/Various.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: June 10, 2015 20 | * Authors: Vincent KUBICKI , 21 | **/ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace mixt { 30 | 31 | void writeProgress(int group, int groupMax, int iteration, int iterationMax) { 32 | Real groupSize = 1. / (Real) (groupMax + 1); // group size in the progress bar 33 | Real startPoint = (Real) group / (Real) (groupMax + 1); 34 | Real inGroupPoint = (Real) iteration / (Real) (iterationMax + 1); 35 | Real globalPoint = startPoint + inGroupPoint * groupSize; 36 | 37 | std::ofstream myfile; 38 | if (const char* env_p = std::getenv("WORKER_PROGRESS_FILE")) { // has the WORKER_PROGRESS_FILE variable been defined ? 39 | myfile.open(env_p, std::ios::out | std::ios::binary); 40 | } else { 41 | myfile.open(progressFile.c_str(), std::ios::out | std::ios::binary); 42 | } 43 | myfile << globalPoint; 44 | myfile.close(); 45 | } 46 | 47 | } // namespace mixt 48 | -------------------------------------------------------------------------------- /MixtComp/src/lib/Various/Various.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: June 10, 2015 20 | * Authors: Vincent KUBICKI , 21 | **/ 22 | 23 | #ifndef VARIOUS_H_ 24 | #define VARIOUS_H_ 25 | 26 | namespace mixt { 27 | 28 | void writeProgress(int group, int groupMax, int iteration, int iterationMax); 29 | 30 | } // namespace mixt 31 | 32 | #endif /* VARIOUS_H_ */ 33 | -------------------------------------------------------------------------------- /MixtComp/src/utest/CMakeLists.txt.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(googletest-download NONE) 4 | 5 | include(ExternalProject) 6 | ExternalProject_Add(googletest 7 | GIT_REPOSITORY https://github.com/google/googletest.git 8 | GIT_TAG main 9 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" 10 | BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" 11 | CONFIGURE_COMMAND "" 12 | BUILD_COMMAND "" 13 | INSTALL_COMMAND "" 14 | TEST_COMMAND "" 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /MixtComp/src/utest/Functional/UTestFuncCSMixture.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: July 5, 2016 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include "gtest/gtest.h" 24 | #include "MixtComp.h" 25 | 26 | using namespace mixt; 27 | 28 | /** 29 | * Test if the FuncCSMixture compiles. As it is a template class, it needs to be instancied to be compiled. So here we go. 30 | */ 31 | TEST(FuncCSMixture, compilation) { 32 | Vector > classInd; 33 | 34 | // FuncCSMixture dummyFunctionalMixture(classInd); 38 | } 39 | -------------------------------------------------------------------------------- /MixtComp/src/utest/LinAlgStat/names.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 21, 2018 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include "gtest/gtest.h" 24 | #include "MixtComp.h" 25 | 26 | using namespace mixt; 27 | 28 | TEST(names, real) { 29 | ASSERT_EQ(names::name, std::string("Real")); 30 | } 31 | -------------------------------------------------------------------------------- /MixtComp/src/utest/Statistic/UTestPoissonStatistic.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * UTestPoissonStatistic.cpp 19 | * 20 | * Created on: 17 déc. 2018 21 | * Author: Quentin Grimonprez 22 | */ 23 | 24 | #include "gtest/gtest.h" 25 | #include "MixtComp.h" 26 | 27 | using namespace mixt; 28 | 29 | 30 | TEST(PoissonStatistic, sample) { 31 | Real lambda = 4.; 32 | int infBound = 3; 33 | int supBound = 6; 34 | 35 | PoissonStatistic pois; 36 | 37 | 38 | for(int i = 0; i < 10; ++i) 39 | { 40 | int xI = pois.sampleI(lambda, infBound, supBound); 41 | int xIB = pois.sampleIB(lambda, infBound); 42 | 43 | EXPECT_GE(xI, infBound); 44 | EXPECT_LE(xI, supBound); 45 | EXPECT_GE(xIB, infBound); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /MixtComp/src/utest/Statistic/UTestRNG.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: January the 23rd, 2018 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include "gtest/gtest.h" 24 | #include "MixtComp.h" 25 | 26 | using namespace mixt; 27 | 28 | /** 29 | * The deterministic mode must be enabled for the unit-test results to be meaningful. 30 | */ 31 | TEST(RNG, deterministicMode) { 32 | ASSERT_EQ(true, deterministicMode()); 33 | } 34 | -------------------------------------------------------------------------------- /MixtComp/src/utest/Statistic/UTestWeibullStatistic.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: January the 23rd, 2018 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include "gtest/gtest.h" 24 | #include "MixtComp.h" 25 | 26 | using namespace mixt; 27 | 28 | /** 29 | * Numerically check that lpdf is correctly computed. 30 | * */ 31 | TEST(WeibullStatistic, DistributionFunctions) { 32 | Real k = 2.3; 33 | Real lambda = 0.9; 34 | Real obs = 3.0; 35 | 36 | WeibullStatistic weibull; 37 | 38 | Real directPDF = weibull.pdf(obs, k, lambda); 39 | Real directLPDF = weibull.lpdf(obs, k, lambda); 40 | 41 | ASSERT_NEAR(std::log(directPDF), directLPDF, epsilon); 42 | } 43 | -------------------------------------------------------------------------------- /MixtComp/src/utest/Various/UTestStandardLibrary.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: September 28, 2015 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include "gtest/gtest.h" 24 | #include "MixtComp.h" 25 | 26 | using namespace mixt; 27 | 28 | /* This is not really a file to test the standard library, but rather to provide example of its use in MixtComp, on 29 | * simple, isolated cases. */ 30 | 31 | TEST(set, intersection) 32 | { 33 | std::set s; 34 | s.insert(1); 35 | s.insert(2); 36 | s.insert(3); 37 | s.insert(12); 38 | 39 | std::vector v; 40 | v.push_back(1); 41 | v.push_back(3); 42 | v.push_back(4); 43 | 44 | std::list intersection; 45 | 46 | std::set_intersection(s.begin(), 47 | s.end(), 48 | v.begin(), 49 | v.end(), 50 | std::back_inserter(intersection)); 51 | 52 | ASSERT_EQ(itString(intersection), "1 3"); 53 | } 54 | -------------------------------------------------------------------------------- /MixtComp/src/utest/Various/UTestVarious.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: September 2, 2015 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include "gtest/gtest.h" 24 | #include "MixtComp.h" 25 | 26 | using namespace mixt; 27 | 28 | TEST(itString, simpleTest) 29 | { 30 | Vector a(3); 31 | a << 0.2, 0.7, 0.3; 32 | 33 | ASSERT_EQ(itString(a), "0.2 0.7 0.3"); 34 | } 35 | -------------------------------------------------------------------------------- /MixtComp/utest.sh: -------------------------------------------------------------------------------- 1 | cd build/ && make runUtest && cd .. 2 | MC_DETERMINISTIC=T build/utest/runUtest --gtest_output=xml:report.xml 3 | -------------------------------------------------------------------------------- /MixtComp/utestCoverage.sh: -------------------------------------------------------------------------------- 1 | cd build/ && MC_DETERMINISTIC=T make MixtComp_coverage && cd .. 2 | -------------------------------------------------------------------------------- /MixtComp/valgrindRun.sh: -------------------------------------------------------------------------------- 1 | MC_DETERMINISTIC=T valgrind --xml=yes --xml-file=valgrindReport.xml build/utest/runUtest --gtest_output=xml:uTestReport.xml 2 | -------------------------------------------------------------------------------- /RJMixtComp/.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.txt$ 4 | ^\.json$ 5 | ^\.R$ 6 | progress 7 | update.sh 8 | README.md 9 | RJMCtest.xml 10 | .Rhistory 11 | -------------------------------------------------------------------------------- /RJMixtComp/BinaryFiles: -------------------------------------------------------------------------------- 1 | inst/exeMixtComp/jmc 2 | -------------------------------------------------------------------------------- /RJMixtComp/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: RJMixtComp 2 | Type: Package 3 | Title: R Interface of JMixtComp 4 | Version: 4.0.0 5 | Date: 2020-05-27 6 | Authors@R: c(person("Vincent", "Kubicki", role = "aut"), 7 | person("Étienne", "Goffinet", role = "ctb"), 8 | person("Christophe", "Biernacki", role = "aut"), 9 | person("Quentin", "Grimonprez", role = c("aut", "cre"), email = "quentin.grimonprez@inria.fr"), 10 | person("Matthieu", "Marbac-Lourdelle", role = "ctb"), 11 | person("Serge", "Iovleff", role = "ctb")) 12 | Description: Mixture Composer is a project to build mixture models with 13 | heterogeneous data sets. 14 | License: AGPL-3 15 | Copyright: Inria - Université de Lille - CNRS 16 | Imports: jsonlite 17 | Depends: RMixtCompUtilities 18 | Suggests: testthat, jsonlite 19 | Encoding: UTF-8 20 | RoxygenNote: 7.1.0 21 | -------------------------------------------------------------------------------- /RJMixtComp/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(JMixtCompLearn) 4 | export(JMixtCompPredict) 5 | import(RMixtCompUtilities) 6 | import(jsonlite) 7 | -------------------------------------------------------------------------------- /RJMixtComp/R/convertRobjectToJson.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4.0 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | # @author Quentin Grimonprez 18 | createAlgoJson <- function(nClass, nInd, mcStrategy, mode) 19 | { 20 | toKeep <- names(mcStrategy) %in% names(createAlgo()) 21 | unrequiredFields = mcStrategy[!toKeep] 22 | 23 | algo = c(list(nClass = nClass, nInd = nInd), RMixtCompUtilities:::completeAlgo(mcStrategy[toKeep]), 24 | list(mode = mode), unrequiredFields) 25 | 26 | return(toJSON(algo, auto_unbox = TRUE, pretty = TRUE)) 27 | } 28 | 29 | # @param data a data.frame where each column corresponds to a variable 30 | # @author Quentin Grimonprez 31 | createDataJson <- function(data) 32 | { 33 | data = RMixtCompUtilities:::formatData(data) 34 | toJSON(data, auto_unbox = FALSE, pretty = TRUE) 35 | } 36 | 37 | 38 | 39 | # @param descriptor a data.frame where each column corresponds to a variable. Each column contains the model and eventually supplementary parameters 40 | # @author Quentin Grimonprez 41 | createModelJson <- function(model) 42 | { 43 | model <- RMixtCompUtilities:::formatModel(model) 44 | toJSON(model, auto_unbox = TRUE, pretty = TRUE) 45 | } -------------------------------------------------------------------------------- /RJMixtComp/R/packageDescription.R: -------------------------------------------------------------------------------- 1 | #' @import jsonlite RMixtCompUtilities 2 | #' 3 | #' @title RJMixtComp 4 | #' @docType package 5 | #' @aliases RJMixtComp-package 6 | #' @name RJMixtComp-package 7 | #' @description 8 | #' Mixture Composer is a project to build mixture models with heterogeneous data sets. The conditional independence property enable composing all the data sets in a single mixture model. 9 | #' 10 | #' 11 | #' @details 12 | #' Use JMixtComp library. 13 | #' 14 | #' 15 | #' @author 16 | #' For RJMixtComp: Quentin Grimonprez 17 | #' 18 | #' Maintainer: Quentin Grimonprez 19 | #' 20 | #' For JMixtComp: 21 | #' Vincent Kubicki 22 | #' Christophe Biernacki 23 | #' Quentin Grimonprez 24 | #' Serge Iovleff 25 | #' 26 | #' 27 | #' @examples 28 | #' \donttest{ 29 | #' pathToData <- system.file("extdata", "data.json", package = "RJMixtComp") 30 | #' pathToModel <- system.file("extdata", "desc.json", package = "RJMixtComp") 31 | #' 32 | #' data <- as.data.frame(fromJSON(pathToData)) 33 | #' model <- fromJSON(pathToModel) 34 | #' algo <- createAlgo() 35 | #' 36 | #' resLearn <- JMixtCompLearn(data, model, algo = algo, nClass = 2, 37 | #' inputPath = ".", outputFile = "reslearn.json") 38 | #' 39 | #' 40 | #' file.remove("./algo.json", "./model.json", "./data.json") 41 | #' 42 | #' resPredict <- JMixtCompPredict(data, model, algo = algo, nClass = 2, inputPath = ".", 43 | #' paramFile = "reslearn.json", outputFile = "respredict.json") 44 | #' 45 | #' 46 | #' file.remove("./algo.json", "./model.json", "./data.json", "reslearn.json", 47 | #' "respredict.json") 48 | #' } 49 | #' 50 | #' 51 | #' @keywords package 52 | NULL -------------------------------------------------------------------------------- /RJMixtComp/README.md: -------------------------------------------------------------------------------- 1 | # Install RJMixtComp 2 | 3 | This package uses JMixtComp. It requires packages *jsonlite* for managing json files, *roxygen2* for generating the documentation and *testthat* for unit testing. 4 | 5 | ``` 6 | install.packages("jsonlite", repos = "https://cran.rstudio.com") 7 | install.packages(c("roxygen2", "testthat"), repos = "https://cran.rstudio.com") 8 | ``` 9 | 10 | 1. Run `./update.sh` for compiling JMixtComp and copying required files. 11 | 2. Install the package: `R CMD INSTALL --no-multiarch --with-keep.source .` or `CTRL + Shift + B` in RStudio. 12 | -------------------------------------------------------------------------------- /RJMixtComp/RJMixtComp.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace 19 | -------------------------------------------------------------------------------- /RJMixtComp/inst/exeMixtComp/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/RJMixtComp/inst/exeMixtComp/empty -------------------------------------------------------------------------------- /RJMixtComp/inst/extdata/desc.json: -------------------------------------------------------------------------------- 1 | { 2 | "Gaussian1": { 3 | "type": "Gaussian", 4 | "paramStr": "dummyStrTestGaussian" 5 | }, 6 | "Poisson1": { 7 | "type": "Poisson", 8 | "paramStr": "dummyStrTestPoisson" 9 | }, 10 | "Categorical1": { 11 | "type": "Multinomial", 12 | "paramStr": "" 13 | }, 14 | "nBinom1": { 15 | "type": "NegativeBinomial", 16 | "paramStr": "" 17 | }, 18 | "Weibull1": { 19 | "type": "Weibull", 20 | "paramStr": "" 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /RJMixtComp/inst/extdata/functionalData.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/RJMixtComp/inst/extdata/functionalData.RData -------------------------------------------------------------------------------- /RJMixtComp/inst/extdata/rankData.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/RJMixtComp/inst/extdata/rankData.RData -------------------------------------------------------------------------------- /RJMixtComp/man/RJMixtComp-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/packageDescription.R 3 | \docType{package} 4 | \name{RJMixtComp-package} 5 | \alias{RJMixtComp-package} 6 | \title{RJMixtComp} 7 | \description{ 8 | Mixture Composer is a project to build mixture models with heterogeneous data sets. The conditional independence property enable composing all the data sets in a single mixture model. 9 | } 10 | \details{ 11 | Use JMixtComp library. 12 | } 13 | \examples{ 14 | \donttest{ 15 | pathToData <- system.file("extdata", "data.json", package = "RJMixtComp") 16 | pathToModel <- system.file("extdata", "desc.json", package = "RJMixtComp") 17 | 18 | data <- as.data.frame(fromJSON(pathToData)) 19 | model <- fromJSON(pathToModel) 20 | algo <- createAlgo() 21 | 22 | resLearn <- JMixtCompLearn(data, model, algo = algo, nClass = 2, 23 | inputPath = ".", outputFile = "reslearn.json") 24 | 25 | 26 | file.remove("./algo.json", "./model.json", "./data.json") 27 | 28 | resPredict <- JMixtCompPredict(data, model, algo = algo, nClass = 2, inputPath = ".", 29 | paramFile = "reslearn.json", outputFile = "respredict.json") 30 | 31 | 32 | file.remove("./algo.json", "./model.json", "./data.json", "reslearn.json", 33 | "respredict.json") 34 | } 35 | 36 | 37 | } 38 | \author{ 39 | For RJMixtComp: Quentin Grimonprez 40 | 41 | Maintainer: Quentin Grimonprez 42 | 43 | For JMixtComp: 44 | Vincent Kubicki 45 | Christophe Biernacki 46 | Quentin Grimonprez 47 | Serge Iovleff 48 | } 49 | \keyword{package} 50 | -------------------------------------------------------------------------------- /RJMixtComp/tests/testthat.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4.0 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | # @author Quentin Grimonprez 17 | library(testthat) 18 | library(RJMixtComp) 19 | 20 | test_check("RJMixtComp") 21 | -------------------------------------------------------------------------------- /RJMixtComp/update.sh: -------------------------------------------------------------------------------- 1 | cd ../JMixtComp/ 2 | ./clean.sh 3 | ./buildRelease.sh 4 | cp release/lib/jmc ../RJMixtComp/inst/exeMixtComp/jmc 5 | -------------------------------------------------------------------------------- /RMixtComp/.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^./*.csv$ 4 | ^./*.json$ 5 | .Rhistory 6 | .cproject 7 | .project 8 | genDataPackage.R 9 | RMCtest.xml 10 | README.md 11 | ^doc$ 12 | ^Meta$ 13 | -------------------------------------------------------------------------------- /RMixtComp/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: RMixtComp 2 | Type: Package 3 | Title: Mixture Models with Heterogeneous and (Partially) Missing Data 4 | Version: 4.1.4 5 | Date: 2023-06-17 6 | Authors@R: c(person("Vincent", "Kubicki", role = "aut"), 7 | person("Christophe", "Biernacki", role = "aut"), 8 | person("Quentin", "Grimonprez", role = c("aut", "cre"), email = "quentingrim@yahoo.fr"), 9 | person("Matthieu", "Marbac-Lourdelle", role = "ctb"), 10 | person("Étienne", "Goffinet", role = "ctb"), 11 | person("Serge", "Iovleff", role = "ctb"), 12 | person("Julien", "Vandaele", role = "ctb", email = "julien.vandaele@inria.fr")) 13 | Copyright: Inria - Université de Lille - CNRS 14 | License: AGPL-3 15 | Description: Mixture Composer (Biernacki (2015) ) is a project to perform clustering using mixture models with 16 | heterogeneous data and partially missing data. Mixture models are fitted using a SEM algorithm. 17 | It includes 8 models for real, categorical, counting, functional and ranking data. 18 | URL: https://github.com/modal-inria/MixtComp 19 | BugReports: https://github.com/modal-inria/MixtComp/issues 20 | Imports: RMixtCompIO(>= 4.0.4), ggplot2, plotly, scales 21 | Depends: RMixtCompUtilities (>= 4.1.4), R (>= 3.5.0) 22 | Suggests: testthat, xml2, Rmixmod, knitr, ClusVis, rmarkdown 23 | RoxygenNote: 7.2.3 24 | Encoding: UTF-8 25 | VignetteBuilder: knitr 26 | -------------------------------------------------------------------------------- /RMixtComp/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(plot,MixtCompLearn) 4 | S3method(predict,MixtComp) 5 | S3method(print,MixtCompLearn) 6 | S3method(summary,MixtCompLearn) 7 | export(extractMixtCompObject) 8 | export(mixtCompLearn) 9 | export(mixtCompPredict) 10 | export(plotCrit) 11 | export(slopeHeuristic) 12 | import(RMixtCompIO) 13 | import(RMixtCompUtilities) 14 | importFrom(ggplot2,aes_string) 15 | importFrom(ggplot2,geom_line) 16 | importFrom(ggplot2,geom_point) 17 | importFrom(ggplot2,ggplot) 18 | importFrom(ggplot2,labs) 19 | importFrom(ggplot2,scale_x_continuous) 20 | importFrom(graphics,plot) 21 | importFrom(parallel,detectCores) 22 | importFrom(plotly,"%>%") 23 | importFrom(plotly,add_trace) 24 | importFrom(plotly,layout) 25 | importFrom(plotly,plot_ly) 26 | importFrom(scales,pretty_breaks) 27 | importFrom(stats,cov) 28 | importFrom(stats,var) 29 | importFrom(utils,head) 30 | -------------------------------------------------------------------------------- /RMixtComp/NEWS: -------------------------------------------------------------------------------- 1 | v4.1.4 2023-06-17 2 | - add references 3 | - add missing return value in documentation 4 | - change maintainer 5 | - correct vignette URL and index entries 6 | - remove blockcluster from suggested packages 7 | - lint 8 | 9 | v4.1.3 2021-03-29 10 | - add crit param to plotCrit function 11 | - add documentation 12 | - add total time of all runs in MixtCompLearn object 13 | - suggest rmarkdown instead of markdown 14 | 15 | v4.1.2 2020-06-17 16 | - hierarchical mode starts with the model with 1 class 17 | - manage statistics about completed data 18 | 19 | v4.1.1 2020-04-01 20 | - add vignettes 21 | - add predict function 22 | 23 | v4.1.0 2019-12-17 24 | - add slopeHeuristic and extractMixtCompObject functions 25 | - plotCrit's improvement 26 | - add plotData parameter to plot.MixtCompLearn (following the update of RMixtCompUtilities) 27 | - add skip_on_cran() to reduce elapsed time 28 | - add vignettes 29 | 30 | v4.0.2 2019-09-16 31 | - change some parameters in examples and tests 32 | - disable tests that generate unexpected errors on cran 33 | 34 | v4.0.1 2019-09-04 35 | - change some parameters in examples and tests 36 | 37 | v4.0.0 2019-07-22 38 | - change version number 39 | 40 | v0.7 2019-07-02 41 | - move rmc and rmcMultiRun to RMixtCompIO package 42 | 43 | v0.6.1 2019-04-26 44 | - new latent and unobserved initialization 45 | 46 | v0.6 2018-12-18 47 | - add missing values intervals for Weibull, Poisson and NegativeBinomial 48 | 49 | v0.5.1 2018-11-27 50 | - Use nStableCriterion and ratioStableCriterion 51 | - param log exported 52 | 53 | v0.5 2018-11-12 54 | - add hierarchical mode 55 | 56 | v0.4.5 2018-11-08 57 | - add basic mode 58 | - add prostate data 59 | 60 | v0.4 2018-10-24 61 | - use MixtComp v4 62 | - add parallelization 63 | - add ggplot2 plots -------------------------------------------------------------------------------- /RMixtComp/R/miscellaneous.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | #' Extract a MixtComp object 18 | #' 19 | #' Extract a MixtComp object from a MixtCompLearn object 20 | #' 21 | #' @param object \link{mixtCompLearn} output 22 | #' @param K number of classes of the model to extract 23 | #' 24 | #' @return a \code{MixtComp} object containing the clustering model with K classes 25 | #' 26 | #' @examples 27 | #' # run clustering 28 | #' resLearn <- mixtCompLearn(data.frame(x = rnorm(500)), 29 | #' nClass = 1:3, criterion = "ICL", 30 | #' nRun = 1, nCore = 1 31 | #' ) 32 | #' 33 | #' # extract the model with 2 classes 34 | #' clustModel <- extractMixtCompObject(resLearn, K = 2) 35 | #' 36 | #' @author Quentin Grimonprez 37 | #' 38 | #' @export 39 | extractMixtCompObject <- function(object, K) { 40 | if (!("MixtCompLearn" %in% class(object))) { 41 | stop("object must be a MixtCompLearn object.") 42 | } 43 | 44 | if (missing(K)) { 45 | K <- object$algo$nClass 46 | } 47 | 48 | if (length(K) > 1) { 49 | stop("K must be an integer.") 50 | } 51 | 52 | ind <- which(object$nClass == K) 53 | 54 | if (length(ind) == 0) { 55 | stop("K is not a value from object$nClass.") 56 | } 57 | 58 | return(object$res[[ind]]) 59 | } 60 | -------------------------------------------------------------------------------- /RMixtComp/RMixtComp.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageBuildArgs: --resave-data 19 | PackageRoxygenize: rd,collate,namespace 20 | -------------------------------------------------------------------------------- /RMixtComp/data/CanadianWeather.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/RMixtComp/data/CanadianWeather.rda -------------------------------------------------------------------------------- /RMixtComp/data/prostate.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/RMixtComp/data/prostate.rda -------------------------------------------------------------------------------- /RMixtComp/data/simData.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/RMixtComp/data/simData.rda -------------------------------------------------------------------------------- /RMixtComp/data/titanic.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/RMixtComp/data/titanic.rda -------------------------------------------------------------------------------- /RMixtComp/man/extractMixtCompObject.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/miscellaneous.R 3 | \name{extractMixtCompObject} 4 | \alias{extractMixtCompObject} 5 | \title{Extract a MixtComp object} 6 | \usage{ 7 | extractMixtCompObject(object, K) 8 | } 9 | \arguments{ 10 | \item{object}{\link{mixtCompLearn} output} 11 | 12 | \item{K}{number of classes of the model to extract} 13 | } 14 | \value{ 15 | a \code{MixtComp} object containing the clustering model with K classes 16 | } 17 | \description{ 18 | Extract a MixtComp object from a MixtCompLearn object 19 | } 20 | \examples{ 21 | # run clustering 22 | resLearn <- mixtCompLearn(data.frame(x = rnorm(500)), 23 | nClass = 1:3, criterion = "ICL", 24 | nRun = 1, nCore = 1 25 | ) 26 | 27 | # extract the model with 2 classes 28 | clustModel <- extractMixtCompObject(resLearn, K = 2) 29 | 30 | } 31 | \author{ 32 | Quentin Grimonprez 33 | } 34 | -------------------------------------------------------------------------------- /RMixtComp/man/plot.MixtCompLearn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_methods.R 3 | \name{plot.MixtCompLearn} 4 | \alias{plot.MixtCompLearn} 5 | \title{Plot of a \emph{MixtCompLearn} object} 6 | \usage{ 7 | \method{plot}{MixtCompLearn}( 8 | x, 9 | nVarMaxToPlot = 3, 10 | nClass = NULL, 11 | pkg = c("ggplot2", "plotly"), 12 | plotData = c("CI", "Boxplot"), 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{x}{\emph{MixtCompLearn} object} 18 | 19 | \item{nVarMaxToPlot}{number of variables to display} 20 | 21 | \item{nClass}{number of classes of the model to plot} 22 | 23 | \item{pkg}{"ggplot2" or "plotly". Package used to plot} 24 | 25 | \item{plotData}{"CI" or "Boxplot". If "CI", uses \link{plotDataCI} function. If "Boxplot", uses \link{plotDataBoxplot}} 26 | 27 | \item{...}{extra parameter for \link{plotDataCI} or \link{plotDataBoxplot}} 28 | } 29 | \value{ 30 | \code{ggplot2} or \code{plotly} object 31 | } 32 | \description{ 33 | Plot of a \emph{MixtCompLearn} object 34 | } 35 | \examples{ 36 | data(iris) 37 | 38 | # run RMixtComp in unsupervised clustering mode and in basic mode 39 | resLearn <- mixtCompLearn(iris[, -5], nClass = 2:4, nCore = 1) 40 | 41 | plot(resLearn) 42 | plot(resLearn, nClass = 3, plotData = "Boxplot") 43 | 44 | } 45 | \seealso{ 46 | \code{\link{mixtCompLearn}} \code{\link{mixtCompPredict}} 47 | 48 | Other plot: 49 | \code{\link{plotCrit}()} 50 | } 51 | \author{ 52 | Quentin Grimonprez 53 | } 54 | \concept{plot} 55 | -------------------------------------------------------------------------------- /RMixtComp/man/plotCrit.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/PLOT_plotCrit.R 3 | \name{plotCrit} 4 | \alias{plotCrit} 5 | \title{Plot BIC and ICL} 6 | \usage{ 7 | plotCrit(output, crit = c("BIC", "ICL"), pkg = c("ggplot2", "plotly"), ...) 8 | } 9 | \arguments{ 10 | \item{output}{\emph{MixtCompLearn} object} 11 | 12 | \item{crit}{criterion to plot (can be "BIC", "ICL" or c("BIC", "ICL") (default))} 13 | 14 | \item{pkg}{"ggplot2" or "plotly". Package used to plot} 15 | 16 | \item{...}{arguments to be passed to plot_ly} 17 | } 18 | \value{ 19 | \code{ggplot2} or \code{plotly} object 20 | } 21 | \description{ 22 | Plot BIC and ICL with regards to the number of classes 23 | } 24 | \examples{ 25 | data(iris) 26 | 27 | # define the algorithm's parameters 28 | algo <- createAlgo() 29 | 30 | # keep only 3 variables 31 | model <- list( 32 | Petal.Width = "Gaussian", Petal.Length = "Gaussian", 33 | Sepal.Width = "Gaussian", Sepal.Length = "Gaussian" 34 | ) 35 | 36 | # run RMixtComp in unsupervised clustering mode + data as matrix 37 | res <- mixtCompLearn(iris, model, algo, nClass = 1:4, nCore = 1) 38 | 39 | # plot 40 | plotCrit(res) 41 | 42 | } 43 | \seealso{ 44 | Other plot: 45 | \code{\link{plot.MixtCompLearn}()} 46 | } 47 | \author{ 48 | Quentin Grimonprez 49 | } 50 | \concept{plot} 51 | -------------------------------------------------------------------------------- /RMixtComp/man/print.MixtCompLearn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_methods.R 3 | \name{print.MixtCompLearn} 4 | \alias{print.MixtCompLearn} 5 | \title{Print Values} 6 | \usage{ 7 | \method{print}{MixtCompLearn}(x, nVarMaxToPrint = 5, nClass = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{x}{\emph{MixtCompLearn} object} 11 | 12 | \item{nVarMaxToPrint}{number of variables to display (including z_class)} 13 | 14 | \item{nClass}{number of classes of the model to print} 15 | 16 | \item{...}{Not used.} 17 | } 18 | \value{ 19 | No return value, called for side effects 20 | } 21 | \description{ 22 | Print a \emph{MixtCompLearn} object 23 | } 24 | \examples{ 25 | data(iris) 26 | 27 | # run RMixtComp in unsupervised clustering mode and in basic mode 28 | resLearn <- mixtCompLearn(iris[, -5], nClass = 2:4, nCore = 1) 29 | 30 | print(resLearn) 31 | print(resLearn, nClass = 3) 32 | 33 | } 34 | \seealso{ 35 | \code{\link{mixtCompLearn}} \code{\link{mixtCompPredict}} 36 | } 37 | \author{ 38 | Quentin Grimonprez 39 | } 40 | -------------------------------------------------------------------------------- /RMixtComp/man/prostate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_datasets.R 3 | \docType{data} 4 | \name{prostate} 5 | \alias{prostate} 6 | \title{Prostate Cancer Data} 7 | \format{ 8 | A list containing of 2 elements \emph{data} and \emph{model}. 9 | \emph{data} contains 506 individuals described by 12 variables: 10 | \itemize{ 11 | \item Age: Age (Continuous) 12 | \item HG: Index of tumour stage and histolic grade (Continuous) 13 | \item Wt: Weight (Continuous) 14 | \item AP: Serum prostatic acid phosphatase C (Continuous) 15 | \item SBP: Systolic blood pressure (Continuous) 16 | \item PF: Performance rating (Categorical) 17 | \item DBP: Diastolic blood pressure (Continuous) 18 | \item HX: Cardiovascular disease history (Categorical) 19 | \item SG: Serum haemoglobin (Continuous) 20 | \item BM: Bone metastasis (Categorical) 21 | \item SZ: Size of primary tumour (Continuous) 22 | \item EKG: Electrocardiogram code (Categorical) 23 | } 24 | } 25 | \source{ 26 | Yakovlev, Goot and Osipova (1994), The choice of cancer treatment based on covariate information. 27 | Statist. Med., 13: 1575-1581. doi:10.1002/sim.4780131508 28 | } 29 | \usage{ 30 | data(prostate) 31 | } 32 | \description{ 33 | This data set was obtained from a randomized clinical trial comparing four treatments for n = 506 patients 34 | with prostatic cancer grouped on clinical criteria into two Stages 3 and 4 of the disease. 35 | } 36 | \examples{ 37 | \donttest{ 38 | data(prostate) 39 | 40 | algo <- createAlgo(nInitPerClass = 50) 41 | 42 | # run clustering 43 | resLearn <- mixtCompLearn(prostate$data, prostate$model, algo, 44 | nClass = 2:5, criterion = "ICL", 45 | nRun = 3, nCore = 1 46 | ) 47 | 48 | summary(resLearn) 49 | 50 | plot(resLearn) 51 | } 52 | 53 | } 54 | \seealso{ 55 | Other data: 56 | \code{\link{CanadianWeather}}, 57 | \code{\link{simData}}, 58 | \code{\link{titanic}} 59 | } 60 | \concept{data} 61 | \keyword{data} 62 | -------------------------------------------------------------------------------- /RMixtComp/man/simData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_datasets.R 3 | \docType{data} 4 | \name{simData} 5 | \alias{simData} 6 | \title{Simulated Heterogeneous data} 7 | \format{ 8 | A list containing three elements: \emph{dataLearn}, \emph{dataPredict} and \emph{model}. 9 | \itemize{ 10 | \item \emph{dataLearn} is a list containing the data in the three accepted format (list, data.frame and matrix). 11 | Data consists of 200 individuals and 9 variables. 12 | \item \emph{dataPredict} is a list containing the data in the three accepted format (list, data.frame and matrix). 13 | Data consists of 100 individuals and 8 variables. 14 | \item \emph{model} is a list containing the model lists used for clustering \emph{model$unsupervised} 15 | and classification \emph{model$supervised}. 16 | } 17 | } 18 | \usage{ 19 | data(simData) 20 | } 21 | \description{ 22 | Simulated Heterogeneous data 23 | } 24 | \examples{ 25 | data(simData) 26 | str(simData) 27 | 28 | } 29 | \seealso{ 30 | Other data: 31 | \code{\link{CanadianWeather}}, 32 | \code{\link{prostate}}, 33 | \code{\link{titanic}} 34 | } 35 | \concept{data} 36 | \keyword{data} 37 | -------------------------------------------------------------------------------- /RMixtComp/man/summary.MixtCompLearn.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_methods.R 3 | \name{summary.MixtCompLearn} 4 | \alias{summary.MixtCompLearn} 5 | \title{MixtCompLearn Object Summaries} 6 | \usage{ 7 | \method{summary}{MixtCompLearn}(object, nClass = NULL, ...) 8 | } 9 | \arguments{ 10 | \item{object}{\emph{MixtCompLearn} object} 11 | 12 | \item{nClass}{number of classes of the model to print} 13 | 14 | \item{...}{Not used.} 15 | } 16 | \value{ 17 | No return value, called for side effects 18 | } 19 | \description{ 20 | Summary of a \emph{MixtCompLearn} object 21 | } 22 | \examples{ 23 | data(iris) 24 | 25 | # run RMixtComp in unsupervised clustering mode and in basic mode 26 | resLearn <- mixtCompLearn(iris[, -5], nClass = 2:4, nCore = 1) 27 | 28 | summary(resLearn) 29 | summary(resLearn, nClass = 3) 30 | 31 | } 32 | \seealso{ 33 | \code{\link{mixtCompLearn}} \code{print.MixtCompLearn} 34 | } 35 | \author{ 36 | Quentin Grimonprez 37 | } 38 | -------------------------------------------------------------------------------- /RMixtComp/tests/testthat.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | library(testthat) 18 | library(RMixtComp) 19 | 20 | test_check("RMixtComp") 21 | -------------------------------------------------------------------------------- /RMixtComp/tests/testthat/test.miscellaneous.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | # @author Quentin Grimonprez 18 | 19 | context("Miscellaneous") 20 | 21 | 22 | test_that("extractMixtCompObject works", { 23 | resLearn <- list( 24 | algo = list(nClass = 2), nClass = 2:5, 25 | res = list( 26 | list(algo = list(nClass = 2)), 27 | list(algo = list(nClass = 3)), 28 | list(algo = list(nClass = 4)), 29 | list(algo = list(nClass = 5)) 30 | ) 31 | ) 32 | class(resLearn) <- c("MixtCompLearn", "MixtComp") 33 | for (i in seq_along(resLearn$res)) { 34 | class(resLearn$res[[i]]) <- "MixtComp" 35 | } 36 | 37 | out <- extractMixtCompObject(resLearn, 2) 38 | expect_equal(class(out), "MixtComp") 39 | expect_equal(out$algo$nClass, 2) 40 | 41 | out <- extractMixtCompObject(resLearn) 42 | expect_equal(class(out), "MixtComp") 43 | expect_equal(out$algo$nClass, resLearn$algo$nClass) 44 | 45 | expect_error(extractMixtCompObject(resLearn, 3.5)) 46 | expect_error(extractMixtCompObject(resLearn, 2:3)) 47 | expect_error(extractMixtCompObject(5)) 48 | }) 49 | -------------------------------------------------------------------------------- /RMixtComp/tests/testthat/test.slopeHeuristic.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | # @author Quentin Grimonprez 18 | context("Slope heuristic") 19 | 20 | test_that("computeCSlopeHeuristic works", { 21 | indD0 <- 1 22 | logLikeObs <- (1:10) * 2 23 | nFreeParam <- 1:10 24 | 25 | C <- computeCSlopeHeuristic(logLikeObs, nFreeParam, indD0) 26 | 27 | expect_equal(C, 2) 28 | 29 | 30 | indD0 <- 5 31 | C <- computeCSlopeHeuristic(logLikeObs, nFreeParam, indD0) 32 | 33 | expect_equal(C, 2) 34 | 35 | 36 | indD0 <- 5 37 | logLikeObs <- c(1:4, (5:10) * 2) 38 | nFreeParam <- 1:10 39 | 40 | C <- computeCSlopeHeuristic(logLikeObs, nFreeParam, indD0) 41 | 42 | expect_equal(C, 2) 43 | }) 44 | 45 | 46 | 47 | test_that("computeCSlopeHeuristic manages NA, NaN and Inf", { 48 | indD0 <- 1 49 | logLikeObs <- (1:10) * 2 50 | nFreeParam <- 1:10 51 | 52 | logLikeObs[10] <- NA 53 | C <- computeCSlopeHeuristic(logLikeObs, nFreeParam, indD0) 54 | expect_equal(C, 2) 55 | 56 | 57 | logLikeObs[10] <- Inf 58 | C <- computeCSlopeHeuristic(logLikeObs, nFreeParam, indD0) 59 | expect_equal(C, 2) 60 | 61 | 62 | logLikeObs[10] <- NaN 63 | C <- computeCSlopeHeuristic(logLikeObs, nFreeParam, indD0) 64 | expect_equal(C, 2) 65 | }) 66 | -------------------------------------------------------------------------------- /RMixtCompHier/.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | progress 4 | RMCHiertest.xml 5 | -------------------------------------------------------------------------------- /RMixtCompHier/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: RMixtCompHier 2 | Type: Package 3 | Date: 2019-07-04 4 | Title: Hierarchical Mixtcomp 5 | Version: 4.0.0 6 | Authors@R: c(person("Vincent", "Kubicki", role = "aut"), 7 | person("Étienne", "Goffinet", role = "aut"), 8 | person("Christophe", "Biernacki", role = "aut"), 9 | person("Quentin", "Grimonprez", role = c("aut", "cre"), email = "quentin.grimonprez@inria.fr"), 10 | person("Matthieu", "Marbac-Lourdelle", role = "ctb"), 11 | person("Serge", "Iovleff", role = "ctb")) 12 | Copyright: Inria - Université de Lille - CNRS 13 | License: AGPL-3 14 | Description: Allow to launch MixtComp hierarchically, in both learn and predict mode. 15 | LazyData: true 16 | Imports: plotly, doParallel, RColorBrewer, jsonlite, foreach, parallel, RJMixtComp 17 | Suggests: testthat 18 | RoxygenNote: 6.1.1 19 | Encoding: UTF-8 20 | -------------------------------------------------------------------------------- /RMixtCompHier/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(aggregate_classification_probabilities) 4 | export(aggregate_clusters) 5 | export(aggregate_completed) 6 | export(convertFunctional) 7 | export(createFunctional) 8 | export(getData) 9 | export(launch_Mixtcomp_Hierarchical) 10 | export(launch_Mixtcomp_Hierarchical_predict) 11 | export(linesFunctional) 12 | export(plotFunctional) 13 | export(plot_categorical_hierarchique) 14 | export(plot_functional_hierarchique) 15 | export(plot_proportion_hierarchique) 16 | export(plot_quality_pred_hierarchique) 17 | export(prune_hierarchy) 18 | import(RColorBrewer) 19 | import(RJMixtComp) 20 | import(doParallel) 21 | import(foreach) 22 | import(jsonlite) 23 | import(parallel) 24 | import(plotly) 25 | importFrom(grDevices,colorRampPalette) 26 | importFrom(graphics,lines) 27 | importFrom(graphics,plot) 28 | importFrom(stats,aggregate) 29 | importFrom(stats,rnorm) 30 | importFrom(stats,runif) 31 | importFrom(stats,setNames) 32 | importFrom(utils,read.csv) 33 | importFrom(utils,read.table) 34 | importFrom(utils,write.table) 35 | -------------------------------------------------------------------------------- /RMixtCompHier/R/RMixtCompHier-package.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4.0 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | #' @import plotly 18 | #' @import doParallel 19 | #' @import RColorBrewer 20 | #' @import jsonlite 21 | #' @import foreach 22 | #' @import parallel 23 | #' @import RJMixtComp 24 | #' @importFrom graphics lines plot 25 | #' @importFrom utils read.table write.table read.csv 26 | #' @importFrom grDevices colorRampPalette 27 | #' @importFrom stats aggregate rnorm runif setNames 28 | #' 29 | #' @title RMixtCompHier 30 | #' @docType package 31 | #' @aliases RMixtCompHier-package 32 | #' @name RMixtCompHier-package 33 | #' 34 | #' @description 35 | #' Allow to launch MixtComp hierarchically, in both learn and predict mode. 36 | #' 37 | #' @seealso \code{\link{launch_Mixtcomp_Hierarchical}} 38 | #' 39 | #' 40 | #' @keywords package 41 | NULL 42 | -------------------------------------------------------------------------------- /RMixtCompHier/README.md: -------------------------------------------------------------------------------- 1 | # MixtCompRTools 2 | 3 | This package uses *JsonMixtComp* (old MixtComp version) to perform hierarchical clustering. It requires packages *roxygen2* for genetaring the documentation and *testthat* for unit testing. 4 | 5 | ``` 6 | install.packages(c("plotly", "doParallel", "RColorBrewer", "jsonlite", "foreach", "parallel"), repos = "https://cran.rstudio.com") 7 | install.packages(c("roxygen2", "testthat"), repos = "https://cran.rstudio.com") 8 | ``` 9 | 10 | To install RJMixtComp see the [instructions](../RJMixtComp/README.md) in the [RJMixtComp fodler](../RJMixtComp/). 11 | -------------------------------------------------------------------------------- /RMixtCompHier/RMixtCompHier.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /RMixtCompHier/inst/exe/JsonMixtComp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/RMixtCompHier/inst/exe/JsonMixtComp -------------------------------------------------------------------------------- /RMixtCompHier/man/RMixtCompHier-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/RMixtCompHier-package.R 3 | \docType{package} 4 | \name{RMixtCompHier-package} 5 | \alias{RMixtCompHier-package} 6 | \title{RMixtCompHier} 7 | \description{ 8 | Allow to launch MixtComp hierarchically, in both learn and predict mode. 9 | } 10 | \seealso{ 11 | \code{\link{launch_Mixtcomp_Hierarchical}} 12 | } 13 | \keyword{package} 14 | -------------------------------------------------------------------------------- /RMixtCompHier/man/aggregate_classification_probabilities.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/aggregate_results.r 3 | \name{aggregate_classification_probabilities} 4 | \alias{aggregate_classification_probabilities} 5 | \title{Aggregate the classification probabilities estimated in the nested clustering} 6 | \usage{ 7 | aggregate_classification_probabilities(dir, depth) 8 | } 9 | \arguments{ 10 | \item{dir}{String, path of the directory in which to finc the nested clustering} 11 | 12 | \item{depth}{Positive Integer, maximum depth of the subclustering to plot} 13 | } 14 | \value{ 15 | tik 16 | } 17 | \description{ 18 | Aggregate the classification probabilities estimated in the nested clustering 19 | } 20 | \seealso{ 21 | Other results aggregation: \code{\link{aggregate_clusters}}, 22 | \code{\link{aggregate_completed}} 23 | } 24 | \author{ 25 | Étienne Goffinet 26 | } 27 | \concept{results aggregation} 28 | -------------------------------------------------------------------------------- /RMixtCompHier/man/aggregate_clusters.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/aggregate_results.r 3 | \name{aggregate_clusters} 4 | \alias{aggregate_clusters} 5 | \title{Aggregate the hierarchical clusters estimated} 6 | \usage{ 7 | aggregate_clusters(dir, depth = NULL) 8 | } 9 | \arguments{ 10 | \item{dir}{String, a path to the directory in which are the subclusters to be aggregated} 11 | 12 | \item{depth}{Positive Integer or NULL, maximum depth of the subclustering to plot. If NULL, the maximal depth of the clusters is assumed.} 13 | } 14 | \description{ 15 | Aggregate the hierarchical clusters estimated 16 | } 17 | \seealso{ 18 | Other results aggregation: \code{\link{aggregate_classification_probabilities}}, 19 | \code{\link{aggregate_completed}} 20 | } 21 | \author{ 22 | Étienne Goffinet 23 | } 24 | \concept{results aggregation} 25 | -------------------------------------------------------------------------------- /RMixtCompHier/man/aggregate_completed.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/aggregate_results.r 3 | \name{aggregate_completed} 4 | \alias{aggregate_completed} 5 | \title{Aggregate the hierarchical clusters completed data} 6 | \usage{ 7 | aggregate_completed(dir, var, depth = NULL) 8 | } 9 | \arguments{ 10 | \item{dir}{String, path of the directory in which to finc the nested clustering} 11 | 12 | \item{var}{String, The name of the functional data to plot} 13 | 14 | \item{depth}{Positive Integer or NULL, maximum depth of the subclustering to plot. If NULL, the maximal depth of the clusters is assumed.} 15 | } 16 | \value{ 17 | completed data 18 | } 19 | \description{ 20 | Aggregate the hierarchical clusters completed data 21 | } 22 | \seealso{ 23 | Other results aggregation: \code{\link{aggregate_classification_probabilities}}, 24 | \code{\link{aggregate_clusters}} 25 | } 26 | \author{ 27 | Étienne Goffinet 28 | } 29 | \concept{results aggregation} 30 | -------------------------------------------------------------------------------- /RMixtCompHier/man/convertFunctional.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{convertFunctional} 4 | \alias{convertFunctional} 5 | \title{Convert a mixtcomp string into 2-columns matrix} 6 | \usage{ 7 | convertFunctional(x) 8 | } 9 | \arguments{ 10 | \item{x}{a string containing a fonctional observation (cf example)} 11 | } 12 | \value{ 13 | matrix 14 | } 15 | \description{ 16 | Convert a mixtcomp string into 2-columns matrix 17 | } 18 | \examples{ 19 | convertFunctional("1:5,1.5:12,1.999:2.9") 20 | 21 | } 22 | \author{ 23 | Quentin Grimonprez 24 | } 25 | -------------------------------------------------------------------------------- /RMixtCompHier/man/createFunctional.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{createFunctional} 4 | \alias{createFunctional} 5 | \title{Create a functional in MixtComp format} 6 | \usage{ 7 | createFunctional(time, value) 8 | } 9 | \arguments{ 10 | \item{time}{vector containing the time of the functional} 11 | 12 | \item{value}{vector containing the value of the functional} 13 | } 14 | \value{ 15 | The functional data formatted to the mixtcomp standard 16 | } 17 | \description{ 18 | Create a functional in MixtComp format 19 | } 20 | \examples{ 21 | mat <- matrix(c(1, 2, 3, 9, 1, 1.5, 15, 1000), ncol=2) 22 | createFunctional(mat[,1], mat[,2]) 23 | 24 | } 25 | \author{ 26 | Quentin Grimonprez 27 | } 28 | -------------------------------------------------------------------------------- /RMixtCompHier/man/getData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/data_processing_for_mixtcomp.r 3 | \name{getData} 4 | \alias{getData} 5 | \title{Transform data into Mixtcomp accepted format} 6 | \usage{ 7 | getData(...) 8 | } 9 | \arguments{ 10 | \item{...}{List of arguments (usually equal to c(data_path, descriptor_path))} 11 | } 12 | \value{ 13 | list of data 14 | } 15 | \description{ 16 | Transform data into Mixtcomp accepted format 17 | } 18 | \author{ 19 | Vincent Kubicki 20 | } 21 | -------------------------------------------------------------------------------- /RMixtCompHier/man/linesFunctional.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{linesFunctional} 4 | \alias{linesFunctional} 5 | \title{lines functional data} 6 | \usage{ 7 | linesFunctional(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Functional data in mixtcomp string format} 11 | 12 | \item{...}{additional plot parameter} 13 | } 14 | \description{ 15 | lines functional data 16 | } 17 | \examples{ 18 | plotFunctional("1:5,3:2,6:9.78,9:4,12:25") 19 | linesFunctional("1:7,3:4,6:11.78,9:5,12:12") 20 | 21 | 22 | } 23 | \author{ 24 | Quentin Grimonprez 25 | } 26 | -------------------------------------------------------------------------------- /RMixtCompHier/man/plotFunctional.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toolbox.R 3 | \name{plotFunctional} 4 | \alias{plotFunctional} 5 | \title{Plot functional data} 6 | \usage{ 7 | plotFunctional(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Functional data in mixtcomp string format} 11 | 12 | \item{...}{additional plot parameter} 13 | } 14 | \description{ 15 | Plot functional data 16 | } 17 | \examples{ 18 | plotFunctional("1:5,3:2,6:9.78,9:4,12:25") 19 | 20 | } 21 | \author{ 22 | Quentin Grimonprez 23 | } 24 | -------------------------------------------------------------------------------- /RMixtCompHier/man/plot_categorical_hierarchique.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/visualisation.r 3 | \name{plot_categorical_hierarchique} 4 | \alias{plot_categorical_hierarchique} 5 | \title{Plot categorical data by clusters} 6 | \usage{ 7 | plot_categorical_hierarchique(clusters, var, data, depth, 8 | dictionary = NULL, order_by = NULL, source = NULL) 9 | } 10 | \arguments{ 11 | \item{clusters}{vector of the clusters associated with data} 12 | 13 | \item{var}{String, The name of the categorical data to plot} 14 | 15 | \item{data}{the data to be plotted} 16 | 17 | \item{depth}{Positive Integer, maximum depth of the subclustering to plot} 18 | 19 | \item{dictionary}{(optional) List, the dictionary in which are stored the real names of the categorical data levels} 20 | 21 | \item{order_by}{(optional) element among : size or purity, which define the order of the different cluster in the histogram.} 22 | 23 | \item{source}{(optional) A string specifying the name of the source to be added to the plotly plot (in case the plot is used in a shiny app)} 24 | } 25 | \value{ 26 | a plotly plot 27 | } 28 | \description{ 29 | Plot categorical data by clusters 30 | } 31 | \seealso{ 32 | Other visualization: \code{\link{plot_functional_hierarchique}}, 33 | \code{\link{plot_proportion_hierarchique}}, 34 | \code{\link{plot_quality_pred_hierarchique}} 35 | } 36 | \author{ 37 | Étienne Goffinet 38 | } 39 | \concept{visualization} 40 | -------------------------------------------------------------------------------- /RMixtCompHier/man/plot_functional_hierarchique.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/visualisation.r 3 | \name{plot_functional_hierarchique} 4 | \alias{plot_functional_hierarchique} 5 | \title{Plot functional data by clusters} 6 | \usage{ 7 | plot_functional_hierarchique(clusters, var, data_func, depth, 8 | max_nb_lines = 100, which_to_highlight = NULL) 9 | } 10 | \arguments{ 11 | \item{clusters}{vector of the clusters associated with data} 12 | 13 | \item{var}{String, The name of the functional data to plot} 14 | 15 | \item{data_func}{list of two elements :time and data / Functional data extracted from Mixtcomp Output} 16 | 17 | \item{depth}{Positive Integer, maximum depth of the subclustering to plot} 18 | 19 | \item{max_nb_lines}{Positive integer, Defines the maximum number of lines to plot (default is 100)} 20 | 21 | \item{which_to_highlight}{String, the name of the cluster to highlight automatically in the plot} 22 | } 23 | \value{ 24 | a plotly plot 25 | } 26 | \description{ 27 | Plot functional data by clusters 28 | } 29 | \seealso{ 30 | Other visualization: \code{\link{plot_categorical_hierarchique}}, 31 | \code{\link{plot_proportion_hierarchique}}, 32 | \code{\link{plot_quality_pred_hierarchique}} 33 | } 34 | \author{ 35 | Étienne Goffinet 36 | } 37 | \concept{visualization} 38 | -------------------------------------------------------------------------------- /RMixtCompHier/man/plot_proportion_hierarchique.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/visualisation.r 3 | \name{plot_proportion_hierarchique} 4 | \alias{plot_proportion_hierarchique} 5 | \title{Plot proportions by clusters} 6 | \usage{ 7 | plot_proportion_hierarchique(clusters, var, data, depth, order_by = NULL) 8 | } 9 | \arguments{ 10 | \item{clusters}{vector of the clusters associated with data} 11 | 12 | \item{var}{String, The name of the categorical data to plot} 13 | 14 | \item{data}{the data to be plotted} 15 | 16 | \item{depth}{Positive Integer, maximum depth of the subclustering to plot} 17 | 18 | \item{order_by}{(optional) element among : size or purity, which define the order of the different cluster in the histogram.} 19 | } 20 | \value{ 21 | a plotly plot 22 | } 23 | \description{ 24 | Plot proportions by clusters 25 | } 26 | \seealso{ 27 | Other visualization: \code{\link{plot_categorical_hierarchique}}, 28 | \code{\link{plot_functional_hierarchique}}, 29 | \code{\link{plot_quality_pred_hierarchique}} 30 | } 31 | \author{ 32 | Étienne Goffinet 33 | } 34 | \concept{visualization} 35 | -------------------------------------------------------------------------------- /RMixtCompHier/man/plot_quality_pred_hierarchique.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/visualisation.r 3 | \name{plot_quality_pred_hierarchique} 4 | \alias{plot_quality_pred_hierarchique} 5 | \title{Plot quality of prediction by clusters} 6 | \usage{ 7 | plot_quality_pred_hierarchique(clusters, var, idx_test, data_observed, 8 | data_completed, depth, order_by = NULL) 9 | } 10 | \arguments{ 11 | \item{clusters}{vector of the clusters associated with data} 12 | 13 | \item{var}{String, The name of the categorical data to plot} 14 | 15 | \item{idx_test}{vector of the index of the test data in the data_observed and data_completed} 16 | 17 | \item{data_observed}{Observed data to be compared with data_completed} 18 | 19 | \item{data_completed}{Completed data} 20 | 21 | \item{depth}{Positive Integer, maximum depth of the subclustering to plot} 22 | 23 | \item{order_by}{(optional) element among : size, purity or quality, which define the order of the different cluster in the histogram.} 24 | } 25 | \value{ 26 | a plotly plot 27 | } 28 | \description{ 29 | Plot quality of prediction by clusters 30 | } 31 | \seealso{ 32 | Other visualization: \code{\link{plot_categorical_hierarchique}}, 33 | \code{\link{plot_functional_hierarchique}}, 34 | \code{\link{plot_proportion_hierarchique}} 35 | } 36 | \author{ 37 | Étienne Goffinet 38 | } 39 | \concept{visualization} 40 | -------------------------------------------------------------------------------- /RMixtCompHier/man/prune_hierarchy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mixtcomp_hierachical_launch.r 3 | \name{prune_hierarchy} 4 | \alias{prune_hierarchy} 5 | \title{Prune a hierarchical clustering. The pruning can be done according to three different strategies} 6 | \usage{ 7 | prune_hierarchy(dir, purity_strategy = list(var = NULL, threshold = 8 | NULL), cluster_size_strategy = list(threshold = NULL)) 9 | } 10 | \arguments{ 11 | \item{dir}{A string, the path of the hierarchical clustering to prune} 12 | 13 | \item{purity_strategy}{a list of two elements (var and threshold), that defines which variable purity to check and according to which threshold (double between 0 and 1)} 14 | 15 | \item{cluster_size_strategy}{a list of one element (threshold) that define the cluster size threshold.} 16 | } 17 | \description{ 18 | - The purity of the clusters : if a cluster is purer than a certain threshold then the subclusters are not useful 19 | - The size of the cluster : below a certain size, a cluster should not have been subclusterized. 20 | - The quality of the completion : Is the global completion more accurate with this subclusterization ? Aims at avoiding overfitting. 21 | } 22 | \details{ 23 | These strategies can be cumulated. 24 | } 25 | \author{ 26 | Etienne Goffinet 27 | } 28 | -------------------------------------------------------------------------------- /RMixtCompHier/tests/testthat.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4.0 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | library(testthat) 18 | library(RMixtCompHier) 19 | 20 | test_check("RMixtCompHier") 21 | -------------------------------------------------------------------------------- /RMixtCompHier/tests/testthat/test.r: -------------------------------------------------------------------------------- 1 | # MixtComp version 4.0 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | # @author Étienne Goffinet 18 | context("Subdir creation") 19 | 20 | test_that("Expand handling", { 21 | expect_error(create_subdirectories("",nClass = 1)) 22 | dir.create(paste0(getwd(),"/wdir"),showWarnings = F) 23 | expect_error(create_subdirectories("tests/wdir",nClass = 0)) 24 | expect_error(create_subdirectories("tests/wdir/",nClass = 0)) 25 | 26 | create_subdirectories("wdir/",nClass = 4) 27 | expect_equal(length(list.dirs("wdir/",recursive = F)),4) 28 | unlink("wdir/",recursive=T) 29 | }) 30 | 31 | 32 | -------------------------------------------------------------------------------- /RMixtCompIO/.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | .Rhistory 4 | Makefile 5 | build.sh 6 | updateLib.py 7 | RMCIOtest.xml 8 | README.md 9 | src/optim/.drone.yml 10 | src/optim/.git 11 | src/optim/.ci 12 | -------------------------------------------------------------------------------- /RMixtCompIO/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: RMixtCompIO 2 | Type: Package 3 | Title: Minimal Interface of the C++ 'MixtComp' Library for Mixture Models with Heterogeneous and (Partially) Missing Data 4 | Version: 4.0.11 5 | Date: 2023-10-03 6 | Authors@R: c(person("Vincent", "Kubicki", role = "aut"), 7 | person("Christophe", "Biernacki", role = "aut"), 8 | person("Quentin", "Grimonprez", role = c("aut", "cre"), email = "quentingrim@yahoo.fr"), 9 | person("Serge", "Iovleff", role = "ctb"), 10 | person("Matthieu", "Marbac-Lourdelle", role = "ctb"), 11 | person("Étienne", "Goffinet", role = "ctb"), 12 | person("Patrick", "Wieschollek", role = "ctb", comment = "for CppOptimizationLibrary"), 13 | person("Tobias", "Wood", role = "ctb", comment = "for CppOptimizationLibrary"), 14 | person("Julien", "Vandaele", role = "ctb", email = "julien.vandaele@inria.fr")) 15 | Copyright: Inria - Université de Lille - CNRS; Patrick Wieschollek, Tobias Wood & the respective contributors for CppOptimizationLibrary 16 | License: AGPL-3 17 | Description: Mixture Composer is a project to build mixture models with 18 | heterogeneous data sets and partially missing data management. 19 | It includes models for real, categorical, counting, functional and ranking data. 20 | This package contains the minimal R interface of the C++ 'MixtComp' library. 21 | URL: https://github.com/modal-inria/MixtComp 22 | BugReports: https://github.com/modal-inria/MixtComp/issues 23 | Imports: Rcpp, doParallel, foreach 24 | Suggests: Rmixmod, testthat, xml2 25 | LinkingTo: Rcpp, RcppEigen, BH 26 | RoxygenNote: 7.2.3 27 | Encoding: UTF-8 28 | -------------------------------------------------------------------------------- /RMixtCompIO/LICENSE.note: -------------------------------------------------------------------------------- 1 | - MixtComp C++ library (src/lib) is licensed under AGPL-3 licence 2 | - CppOptimizationLibrary C++ library (src/optim) is licensed under MIT licence (see src/optim/LICENSE or visit https://github.com/PatWie/CppNumericalSolvers/blob/master/LICENSE) -------------------------------------------------------------------------------- /RMixtCompIO/Makefile: -------------------------------------------------------------------------------- 1 | # MixtComp version 4 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # Note that this Makefile will not be available on CRAN. Make commands should not be called from configure or cleanup scripts. 5 | 6 | all: 7 | Rscript -e "Rcpp::compileAttributes()" 8 | R CMD INSTALL --no-multiarch --with-keep.source . 9 | 10 | clean: 11 | find src -type f -name '*.o' -delete 12 | 13 | updateLib: 14 | python3 updateLib.py 15 | -------------------------------------------------------------------------------- /RMixtCompIO/NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(rmcMultiRun) 4 | import(Rcpp) 5 | import(doParallel) 6 | importFrom(foreach,"%dopar%") 7 | importFrom(foreach,foreach) 8 | importFrom(foreach,registerDoSEQ) 9 | importFrom(parallel,makeCluster) 10 | importFrom(parallel,stopCluster) 11 | importFrom(stats,rbinom) 12 | importFrom(stats,rmultinom) 13 | importFrom(stats,rnbinom) 14 | importFrom(stats,rnorm) 15 | importFrom(stats,rpois) 16 | importFrom(stats,runif) 17 | importFrom(stats,rweibull) 18 | useDynLib(RMixtCompIO) 19 | -------------------------------------------------------------------------------- /RMixtCompIO/NEWS: -------------------------------------------------------------------------------- 1 | v 4.0.11 2023-10-03 2 | - fix cpp errors with clang 17 3 | 4 | v 4.0.10 2023-05-07 5 | - fix cpp warnings 6 | - update negative binomial test 7 | 8 | v 4.0.9 2023-02-11 9 | - lint 10 | - change c++ standard from c++11 to c++17 11 | - correct c++ error with clang16 12 | 13 | v 4.0.8 2022-10-18 14 | - correct bitwise-instead-of-logical warnings 15 | - remove blockcluster as suggested package 16 | 17 | v 4.0.7 2022-01-13 18 | - manage eigen 3.4.0 19 | - lint package 20 | 21 | v 4.0.6 2020-11-13 22 | - catch error "XXX object does not exit." 23 | - rename some C++ classes and files 24 | - remove useless files 25 | - Manage the case when lambda = 0 for Poisson and there are some missing intervals 26 | 27 | v4.0.5 2020-06-15 28 | - bug correction when z_class is in data but not in the model 29 | - bug correction when the number of classes does not correspond to the content of z_class 30 | - new output from MixtComp: IDClassBar 31 | - export statistics about completed data 32 | 33 | v4.0.2 2019-12-16 34 | - correct variable name in a function 35 | - typo in error message 36 | - use registerDoSeq when the number of cores is 1 37 | 38 | v4.0.1 2019-08-29 39 | - Do not use foreach and %dopar% when the number of core is 1 40 | 41 | v4.0.0 2019-07-10 42 | - RMixtCompIO version number now follows MixtComp number version 43 | 44 | v0.1 2019-17-01 45 | - code extracted from RMixtComp 0.6.1 46 | -------------------------------------------------------------------------------- /RMixtCompIO/R/GENDATA_functionalGenerator.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4.0 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | # @author Vincent Kubicki 18 | functionalGenerator <- function(present, param) { 19 | nSub <- nrow(param$alpha) 20 | nCoeff <- ncol(param$beta) 21 | 22 | x <- vector("numeric", param$nTime) 23 | 24 | t <- sort(runif(param$nTime, param$tMin, param$tMax)) 25 | 26 | for (i in seq_len(param$nTime)) { 27 | logKappa <- param$alpha[, 1] + param$alpha[, 2] * t[i] 28 | 29 | kappa <- logToMulti(logKappa) 30 | indSub <- which(rmultinom(1, 1, kappa) == 1) 31 | 32 | xExp <- drop(param$beta[indSub, ] %*% t[i]^((seq_len(nCoeff)) - 1)) 33 | 34 | x[i] <- rnorm(1, xExp, param$sigma[indSub]) 35 | } 36 | 37 | xStr <- paste(t, x, sep = ":", collapse = ",") 38 | 39 | return(xStr) 40 | } 41 | 42 | # @author Vincent Kubicki 43 | logToMulti <- function(logIn) { 44 | max <- max(logIn) 45 | multiOut <- logIn - max 46 | multiOut <- exp(multiOut) 47 | sum <- sum(multiOut) 48 | multiOut <- multiOut / sum 49 | 50 | return(multiOut) 51 | } 52 | -------------------------------------------------------------------------------- /RMixtCompIO/RMixtCompIO.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace 19 | -------------------------------------------------------------------------------- /RMixtCompIO/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -Rf ../*.tar.gz 4 | rm -Rf ../RMixtCompIO.Rcheck 5 | make clean 6 | make updateLib 7 | make all 8 | -------------------------------------------------------------------------------- /RMixtCompIO/cleanup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | find src -type f -name '*.o' -delete 4 | -------------------------------------------------------------------------------- /RMixtCompIO/inst/COPYRIGHTS: -------------------------------------------------------------------------------- 1 | - For CppOptimizationLibrary (src/optim): 2 | Copyright (c) 2014-2015 Patrick Wieschollek 3 | Copyright (c) 2015- Patrick Wieschollek, Tobias Wood and the respective contributors (https://github.com/PatWie/CppNumericalSolvers/graphs/contributors) 4 | 5 | - The rest of the package: 6 | Copyright (c) Inria - Université de Lille - CNRS 7 | -------------------------------------------------------------------------------- /RMixtCompIO/src/CPPToRMatrixType.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS */ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 21, 2018 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef RMIXTCOMP_SRC_CPPTORVECTORTYPE 24 | #define RMIXTCOMP_SRC_CPPTORVECTORTYPE 25 | 26 | #include 27 | #include 28 | 29 | namespace mixt { 30 | 31 | template 32 | class CPPToRMatrixType {}; 33 | 34 | template<> 35 | class CPPToRMatrixType { 36 | public: 37 | typedef Rcpp::IntegerMatrix ctype; 38 | }; 39 | 40 | template<> 41 | class CPPToRMatrixType { 42 | public: 43 | typedef Rcpp::IntegerMatrix ctype; 44 | }; 45 | 46 | template<> 47 | class CPPToRMatrixType { 48 | public: 49 | typedef Rcpp::IntegerMatrix ctype; 50 | }; 51 | 52 | template<> 53 | class CPPToRMatrixType { 54 | public: 55 | typedef Rcpp::NumericMatrix ctype; 56 | }; 57 | 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /RMixtCompIO/src/CPPToRVectorType.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS */ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: August 21, 2018 20 | * Authors: Vincent KUBICKI 21 | **/ 22 | 23 | #ifndef RMIXTCOMP_SRC_CPPTORMATRIXTYPE 24 | #define RMIXTCOMP_SRC_CPPTORMATRIXTYPE 25 | 26 | #include 27 | #include 28 | 29 | namespace mixt { 30 | 31 | template 32 | class CPPToRVectorType {}; 33 | 34 | template<> 35 | class CPPToRVectorType { 36 | public: 37 | typedef Rcpp::IntegerVector ctype; 38 | }; 39 | 40 | template<> 41 | class CPPToRVectorType { 42 | public: 43 | typedef Rcpp::IntegerVector ctype; 44 | }; 45 | 46 | template<> 47 | class CPPToRVectorType { 48 | public: 49 | typedef Rcpp::IntegerVector ctype; 50 | }; 51 | 52 | template<> 53 | class CPPToRVectorType { 54 | public: 55 | typedef Rcpp::NumericVector ctype; 56 | }; 57 | 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /RMixtCompIO/src/test/test.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS */ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: Feb 25, 2014 20 | * Author: Vincent KUBICKI 21 | **/ 22 | 23 | #include // for the embedded R via RInside 24 | #include 25 | 26 | int main(int argc, char *argv[]) { 27 | RInside R(argc, argv); // create an embedded R instance 28 | 29 | // R.parseEvalQ(R"(setwd("/media/sf_Documents/160803 - MixtComp/160803 - debug MixtComp/180129 - Crashs Aléatoires - Etienne"))"); // note the use of string literals to avoid cluttering the R command with escape characters 30 | // R.parseEvalQ(R"(source("run.R"))"); 31 | 32 | // R.parseEvalQ("library(RMixtComp)"); 33 | // R.parseEvalQ("testFunctionalSharedAlpha()"); 34 | // R.parseEvalQ("testOrdinal()"); 35 | // R.parseEvalQ("testRank()"); 36 | // R.parseEvalQ("testCategorical()"); 37 | // R.parseEvalQ("testGaussian()"); 38 | // R.parseEvalQ("testPoisson()"); 39 | // R.parseEvalQ("testWeibull()"); 40 | 41 | // exit(0); 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /RMixtCompIO/tests/testthat.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4.0 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | library(testthat) 18 | library(RMixtCompIO) 19 | 20 | test_check("RMixtCompIO") 21 | -------------------------------------------------------------------------------- /RMixtCompIO/updateLib.py: -------------------------------------------------------------------------------- 1 | #! /usr/local/bin/python3 2 | 3 | # MixtComp version 4 - july 2019 4 | # Copyright (C) Inria - Université de Lille - CNRS 5 | 6 | import glob 7 | import subprocess 8 | import sys 9 | 10 | if sys.version_info[0] < 3 and sys.version_info[1] < 5: 11 | raise Exception("Python 3.5 or a more recent version is required.") 12 | 13 | print("Note that updateLib.py updates the src/lib subdirectory.") 14 | 15 | libSource = "../MixtComp/src/lib" 16 | 17 | subprocess.call(["rsync", "-a", "--delete", libSource, "src"]) 18 | 19 | cppList = glob.iglob("src/lib/**/*.cpp", recursive=True) 20 | oList = [filename[4:-3] + 'o' for filename in cppList] 21 | oListStr = ' '.join(oList) 22 | fileContent = "LIB_OFILES = " + oListStr 23 | 24 | makevarsStr = r'''# MixtComp version 4 - july 2019 25 | # Copyright (C) Inria - Université de Lille - CNRS 26 | # 27 | # 28 | # Project: MixtComp 29 | # Created on: October 10, 2018 30 | # Authors: Vincent KUBICKI 31 | 32 | %s 33 | 34 | PKG_CXXFLAGS = -Ilib -Ilib/LinAlg -DEIGEN_MATRIXBASE_PLUGIN=\"EigenMatrixBaseAddons.h\" -Ioptim/include 35 | CXX_STD = CXX17 36 | 37 | PKG_LIBS = $(LIB_OFILES) 38 | 39 | .PHONY: all # a phony target is a target that is always considered out of date 40 | 41 | all: $(SHLIB) # $(SHLIB) is RMixtCompIO.so or RMixtCompIO.dll 42 | 43 | $(SHLIB): $(LIB_OFILES) 44 | '''%(fileContent) 45 | 46 | text_file = open("src/Makevars", "w") 47 | text_file.write(makevarsStr) 48 | text_file.close() 49 | -------------------------------------------------------------------------------- /RMixtCompUtilities/.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | RMCUttest.xml 4 | .Rhistory 5 | README.md 6 | -------------------------------------------------------------------------------- /RMixtCompUtilities/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: RMixtCompUtilities 2 | Type: Package 3 | Title: Utility Functions for 'MixtComp' Outputs 4 | Version: 4.1.6 5 | Date: 2023-09-21 6 | Authors@R: c(person("Vincent", "Kubicki", role = "aut"), 7 | person("Christophe", "Biernacki", role = "aut"), 8 | person("Quentin", "Grimonprez", role = c("aut", "cre"), email = "quentingrim@yahoo.fr"), 9 | person("Matthieu", "Marbac-Lourdelle", role = "aut"), 10 | person("Étienne", "Goffinet", role = "ctb"), 11 | person("Serge", "Iovleff", role = "ctb"), 12 | person("Julien", "Vandaele", role = "ctb", email = "julien.vandaele@inria.fr")) 13 | Copyright: Inria - Université de Lille - CNRS 14 | License: AGPL-3 15 | Description: Mixture Composer is a project to build mixture models with 16 | heterogeneous data sets and partially missing data management. This package contains graphical, getter and some utility 17 | functions to facilitate the analysis of 'MixtComp' output. 18 | URL: https://github.com/modal-inria/MixtComp 19 | BugReports: https://github.com/modal-inria/MixtComp/issues 20 | Imports: plotly, ggplot2, scales 21 | Suggests: testthat, xml2, RMixtCompIO (>= 4.0.4), Rmixmod 22 | RoxygenNote: 7.2.3 23 | Encoding: UTF-8 24 | -------------------------------------------------------------------------------- /RMixtCompUtilities/NEWS: -------------------------------------------------------------------------------- 1 | v4.1.6 2023-09-25 2 | - use requireNamespace instead of require in examples 3 | 4 | v4.1.5 2023-06-14 5 | - getter functions manage errored mixtComp run 6 | - remove blockcluster from suggested packages 7 | - lint 8 | - change maintainer 9 | 10 | v4.1.4 2020-11-12 11 | - export formatData, completeAlgo and formatModel functions to avoir using RMixtCompUtilities::: in RMixtComp 12 | - add class parameter for functional models in plotDataBoxplot 13 | - change default value of nInitPerClass in createAlgo function 14 | - change default value of empiric in getPartition function 15 | 16 | v4.1.3 2020-10-02 17 | - formatModel manages data.frame and matrix for models with hyperparameters 18 | - bug correction for heatmap* functions with pkg = "plotly" 19 | - use uniroot instead of optimize to find the ci bounds for functional data 20 | - bug corrections in plotDataCI and plotDataBoxplot when using class parameter (color, position, error when combined with grl = TRUE) 21 | - add unexported icl function 22 | - remove colours in barplot functions 23 | - change maintainer 24 | 25 | v4.1.2 2020-06-04 26 | - print.MixtComp prints correctly functional and rank parameters 27 | - add getProportion function 28 | - doc correction 29 | - add class parameter to plotDataBoxplot, plotDiscrimVar and computeDiscrimPowerVar functions 30 | - getCompletedData returns a data.frame with proper column types and returns rank as a string 31 | - label order correction for functional data 32 | 33 | v4.1.0 2019-12-16 34 | - can use grl = TRUE in plot.MixtComp 35 | - add plotData parameter in plot.MixtComp 36 | - bug correction in extractCIPoissonVble when grl = TRUE 37 | - plotDataBoxplot uses ggplot2 and plotly 38 | - plotParamConvergence works for nClass = 1 39 | 40 | v4.0.0 2019-08-27 41 | - On CRAN, Now 42 | 43 | v0.1 2019-07-02 44 | - Extract plot and getter functions from RMixtComp 45 | -------------------------------------------------------------------------------- /RMixtCompUtilities/RMixtCompUtilities.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace 19 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/availableModels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_misc.R 3 | \name{availableModels} 4 | \alias{availableModels} 5 | \title{Available models} 6 | \usage{ 7 | availableModels() 8 | } 9 | \value{ 10 | a data.frame containing models implemented in MixtComp 11 | \describe{ 12 | \item{model}{model name} 13 | \item{data.type}{data type} 14 | \item{format}{Special format required for individuals} 15 | \item{missing.formats}{accepted formats (separated by a ;) for missing values} 16 | \item{hyperparameter}{Required hyperparameters in the paramStr elements of model object} 17 | \item{comments}{comments about the model} 18 | \item{reference}{link to article} 19 | } 20 | } 21 | \description{ 22 | Get information about models implemented in MixtComp 23 | } 24 | \examples{ 25 | availableModels() 26 | 27 | } 28 | \seealso{ 29 | \code{mixtCompLearn} 30 | } 31 | \author{ 32 | Quentin Grimonprez 33 | } 34 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/completeAlgo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_formatParameter.R 3 | \name{completeAlgo} 4 | \alias{completeAlgo} 5 | \title{Add the missing element to algo parameter} 6 | \usage{ 7 | completeAlgo(algo) 8 | } 9 | \arguments{ 10 | \item{algo}{a list with the different algo parameters for rmc function} 11 | } 12 | \value{ 13 | algo parameter with all required elements (see \link{createAlgo} function) 14 | } 15 | \description{ 16 | Add the missing element to algo parameter with default values 17 | } 18 | \author{ 19 | Quentin Grimonprez 20 | } 21 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/convertFunctionalToVector.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_formatFunctions.R 3 | \name{convertFunctionalToVector} 4 | \alias{convertFunctionalToVector} 5 | \title{Convert a MixtComp functional string into a list of 2 vectors} 6 | \usage{ 7 | convertFunctionalToVector(x) 8 | } 9 | \arguments{ 10 | \item{x}{a string containing a functional observation (cf example)} 11 | } 12 | \value{ 13 | a list of 2 vectors: \code{time} and \code{value} 14 | } 15 | \description{ 16 | Convert a MixtComp functional string into a list of 2 vectors 17 | } 18 | \examples{ 19 | convertFunctionalToVector("1:5,1.5:12,1.999:2.9") 20 | 21 | } 22 | \author{ 23 | Quentin Grimonprez 24 | } 25 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/createAlgo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_misc.R 3 | \name{createAlgo} 4 | \alias{createAlgo} 5 | \title{Create algo object} 6 | \usage{ 7 | createAlgo( 8 | nbBurnInIter = 50, 9 | nbIter = 50, 10 | nbGibbsBurnInIter = 50, 11 | nbGibbsIter = 50, 12 | nInitPerClass = 50, 13 | nSemTry = 20, 14 | confidenceLevel = 0.95, 15 | ratioStableCriterion = 0.99, 16 | nStableCriterion = 20 17 | ) 18 | } 19 | \arguments{ 20 | \item{nbBurnInIter}{Number of iterations of the burn-in part of the SEM algorithm.} 21 | 22 | \item{nbIter}{Number of iterations of the SEM algorithm.} 23 | 24 | \item{nbGibbsBurnInIter}{Number of iterations of the burn-in part of the Gibbs algorithm.} 25 | 26 | \item{nbGibbsIter}{Number of iterations of the Gibbs algorithm.} 27 | 28 | \item{nInitPerClass}{Number of individuals used to initialize each cluster.} 29 | 30 | \item{nSemTry}{Number of try of the algorithm for avoiding an error.} 31 | 32 | \item{confidenceLevel}{confidence level for confidence bounds for parameter estimation} 33 | 34 | \item{ratioStableCriterion}{stability partition required to stop earlier the SEM} 35 | 36 | \item{nStableCriterion}{number of iterations of partition stability to stop earlier the SEM} 37 | } 38 | \value{ 39 | a list with the parameters values 40 | } 41 | \description{ 42 | create an algo object required by \code{mixtCompLearn} and \code{mixtCompPredict} from \code{RMixtComp}. 43 | } 44 | \examples{ 45 | # default values 46 | algo <- createAlgo() 47 | 48 | # change some values 49 | algo <- createAlgo(nbIter = 200) 50 | 51 | } 52 | \author{ 53 | Quentin Grimonprez 54 | } 55 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/createFunctional.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_formatFunctions.R 3 | \name{createFunctional} 4 | \alias{createFunctional} 5 | \title{Create a functional in MixtComp format} 6 | \usage{ 7 | createFunctional(time, value) 8 | } 9 | \arguments{ 10 | \item{time}{vector containing the time of the functional} 11 | 12 | \item{value}{vector containing the value of the functional} 13 | } 14 | \value{ 15 | The functional data formatted to the MixtComp standard 16 | } 17 | \description{ 18 | Create a functional in MixtComp format 19 | } 20 | \examples{ 21 | mat <- matrix(c(1, 2, 3, 9, 1, 1.5, 15, 1000), ncol = 2) 22 | createFunctional(mat[, 1], mat[, 2]) 23 | 24 | } 25 | \author{ 26 | Quentin Grimonprez 27 | } 28 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/formatData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_formatParameter.R 3 | \name{formatData} 4 | \alias{formatData} 5 | \title{Format the data parameter required by rmc} 6 | \usage{ 7 | formatData(data) 8 | } 9 | \arguments{ 10 | \item{data}{data parameter as data.frame, matrix or list} 11 | } 12 | \value{ 13 | data as a list of characters 14 | } 15 | \description{ 16 | format data.frame or matrix in list of character 17 | } 18 | \author{ 19 | Quentin Grimonprez 20 | } 21 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/formatModel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_formatParameter.R 3 | \name{formatModel} 4 | \alias{formatModel} 5 | \title{Format the model parameter} 6 | \usage{ 7 | formatModel(model) 8 | } 9 | \arguments{ 10 | \item{model}{description of model used per variable} 11 | } 12 | \value{ 13 | model as a list where each element is the model applied to a variable (list with elements type and paramStr) 14 | } 15 | \description{ 16 | Format the model list for rmc/rmcMultiRun functions: 17 | - add paramStr when missing 18 | - ensure the list format of each element 19 | } 20 | \author{ 21 | Quentin Grimonprez 22 | } 23 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/getBIC.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_getter.R 3 | \name{getBIC} 4 | \alias{getBIC} 5 | \alias{getICL} 6 | \title{Get criterion value} 7 | \usage{ 8 | getBIC(outMixtComp) 9 | 10 | getICL(outMixtComp) 11 | } 12 | \arguments{ 13 | \item{outMixtComp}{object of class \emph{MixtCompLearn} or \emph{MixtComp} obtained using \code{mixtCompLearn} or 14 | \code{mixtCompPredict} functions from \code{RMixtComp} package or \code{rmcMultiRun} from \code{RMixtCompIO} package.} 15 | } 16 | \value{ 17 | value of the criterion 18 | } 19 | \description{ 20 | Get criterion value 21 | } 22 | \examples{ 23 | if (requireNamespace("RMixtCompIO", quietly = TRUE)) { 24 | dataLearn <- list( 25 | var1 = as.character(c(rnorm(50, -2, 0.8), rnorm(50, 2, 0.8))), 26 | var2 = as.character(c(rnorm(50, 2), rpois(50, 8))) 27 | ) 28 | 29 | model <- list( 30 | var1 = list(type = "Gaussian", paramStr = ""), 31 | var2 = list(type = "Poisson", paramStr = "") 32 | ) 33 | 34 | algo <- list( 35 | nClass = 2, 36 | nInd = 100, 37 | nbBurnInIter = 100, 38 | nbIter = 100, 39 | nbGibbsBurnInIter = 100, 40 | nbGibbsIter = 100, 41 | nInitPerClass = 3, 42 | nSemTry = 20, 43 | confidenceLevel = 0.95, 44 | ratioStableCriterion = 0.95, 45 | nStableCriterion = 10, 46 | mode = "learn" 47 | ) 48 | 49 | resLearn <-RMixtCompIO::rmcMultiRun(algo, dataLearn, model, nRun = 3) 50 | 51 | # get criterion 52 | bic <- getBIC(resLearn) 53 | icl <- getICL(resLearn) 54 | } 55 | 56 | } 57 | \seealso{ 58 | Other getter: 59 | \code{\link{getCompletedData}()}, 60 | \code{\link{getEmpiricTik}()}, 61 | \code{\link{getMixtureDensity}()}, 62 | \code{\link{getParam}()}, 63 | \code{\link{getPartition}()}, 64 | \code{\link{getType}()} 65 | } 66 | \author{ 67 | Quentin Grimonprez 68 | } 69 | \concept{getter} 70 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/getMixtureDensity.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_getter.R 3 | \name{getMixtureDensity} 4 | \alias{getMixtureDensity} 5 | \title{Get the mixture density} 6 | \usage{ 7 | getMixtureDensity(outMixtComp) 8 | } 9 | \arguments{ 10 | \item{outMixtComp}{object of class \emph{MixtCompLearn} or \emph{MixtComp} obtained using \code{mixtCompLearn} or 11 | \code{mixtCompPredict} functions from \code{RMixtComp} package or \code{rmcMultiRun} from \code{RMixtCompIO} package.} 12 | } 13 | \value{ 14 | a vector containing the mixture density for each individual. 15 | } 16 | \description{ 17 | Get the mixture density for each individual 18 | } 19 | \details{ 20 | \deqn{d(x_i) = \sum_k\pi_k P(x_i; \theta_k)} 21 | } 22 | \examples{ 23 | if (requireNamespace("RMixtCompIO", quietly = TRUE)) { 24 | dataLearn <- list( 25 | var1 = as.character(c(rnorm(50, -2, 0.8), rnorm(50, 2, 0.8))), 26 | var2 = as.character(c(rnorm(50, 2), rpois(50, 8))) 27 | ) 28 | 29 | model <- list( 30 | var1 = list(type = "Gaussian", paramStr = ""), 31 | var2 = list(type = "Poisson", paramStr = "") 32 | ) 33 | 34 | algo <- list( 35 | nClass = 2, 36 | nInd = 100, 37 | nbBurnInIter = 100, 38 | nbIter = 100, 39 | nbGibbsBurnInIter = 100, 40 | nbGibbsIter = 100, 41 | nInitPerClass = 3, 42 | nSemTry = 20, 43 | confidenceLevel = 0.95, 44 | ratioStableCriterion = 0.95, 45 | nStableCriterion = 10, 46 | mode = "learn" 47 | ) 48 | 49 | resLearn <-RMixtCompIO::rmcMultiRun(algo, dataLearn, model, nRun = 3) 50 | 51 | d <- getMixtureDensity(resLearn) 52 | } 53 | 54 | } 55 | \seealso{ 56 | Other getter: 57 | \code{\link{getBIC}()}, 58 | \code{\link{getCompletedData}()}, 59 | \code{\link{getEmpiricTik}()}, 60 | \code{\link{getParam}()}, 61 | \code{\link{getPartition}()}, 62 | \code{\link{getType}()} 63 | } 64 | \author{ 65 | Quentin Grimonprez 66 | } 67 | \concept{getter} 68 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/print.MixtComp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_methods.R 3 | \name{print.MixtComp} 4 | \alias{print.MixtComp} 5 | \title{Print Values} 6 | \usage{ 7 | \method{print}{MixtComp}(x, nVarMaxToPrint = 5, ...) 8 | } 9 | \arguments{ 10 | \item{x}{\emph{MixtComp} object} 11 | 12 | \item{nVarMaxToPrint}{number of variables to display (including z_class)} 13 | 14 | \item{...}{parameter of \code{head} function} 15 | } 16 | \description{ 17 | Print a \emph{MixtComp} object 18 | } 19 | \examples{ 20 | if (requireNamespace("RMixtCompIO", quietly = TRUE)) { 21 | dataLearn <- list( 22 | var1 = as.character(c(rnorm(50, -2, 0.8), rnorm(50, 2, 0.8))), 23 | var2 = as.character(c(rnorm(50, 2), rpois(50, 8))) 24 | ) 25 | 26 | model <- list( 27 | var1 = list(type = "Gaussian", paramStr = ""), 28 | var2 = list(type = "Poisson", paramStr = "") 29 | ) 30 | 31 | algo <- list( 32 | nClass = 2, 33 | nInd = 100, 34 | nbBurnInIter = 100, 35 | nbIter = 100, 36 | nbGibbsBurnInIter = 100, 37 | nbGibbsIter = 100, 38 | nInitPerClass = 3, 39 | nSemTry = 20, 40 | confidenceLevel = 0.95, 41 | ratioStableCriterion = 0.95, 42 | nStableCriterion = 10, 43 | mode = "learn" 44 | ) 45 | 46 | resLearn <-RMixtCompIO::rmcMultiRun(algo, dataLearn, model, nRun = 3) 47 | 48 | print(resLearn) 49 | } 50 | 51 | } 52 | \seealso{ 53 | \code{mixtCompLearn} \code{mixtCompPredict} 54 | } 55 | \author{ 56 | Quentin Grimonprez 57 | } 58 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/refactorCategorical.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_formatFunctions.R 3 | \name{refactorCategorical} 4 | \alias{refactorCategorical} 5 | \title{Rename a categorical value} 6 | \usage{ 7 | refactorCategorical( 8 | data, 9 | oldCateg = unique(data), 10 | newCateg = seq_along(oldCateg) 11 | ) 12 | } 13 | \arguments{ 14 | \item{data}{matrix/data.frame/vector containing the data} 15 | 16 | \item{oldCateg}{vector containing categories to change} 17 | 18 | \item{newCateg}{vector containing new categorical values} 19 | } 20 | \value{ 21 | Data with new categorical values 22 | } 23 | \description{ 24 | Rename a categorical value 25 | } 26 | \examples{ 27 | dat <- c("single", "married", "married", "divorced", "single") 28 | refactorCategorical(dat, c("single", "married", "divorced"), 1:3) 29 | 30 | } 31 | \author{ 32 | Quentin Grimonprez 33 | } 34 | -------------------------------------------------------------------------------- /RMixtCompUtilities/man/summary.MixtComp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/MIXTCOMP_methods.R 3 | \name{summary.MixtComp} 4 | \alias{summary.MixtComp} 5 | \title{MixtComp Object Summaries} 6 | \usage{ 7 | \method{summary}{MixtComp}(object, ...) 8 | } 9 | \arguments{ 10 | \item{object}{\emph{MixtComp} object} 11 | 12 | \item{...}{Not used.} 13 | } 14 | \description{ 15 | Summary of a \emph{MixtComp} object 16 | } 17 | \examples{ 18 | if (requireNamespace("RMixtCompIO", quietly = TRUE)) { 19 | dataLearn <- list( 20 | var1 = as.character(c(rnorm(50, -2, 0.8), rnorm(50, 2, 0.8))), 21 | var2 = as.character(c(rnorm(50, 2), rpois(50, 8))) 22 | ) 23 | 24 | model <- list( 25 | var1 = list(type = "Gaussian", paramStr = ""), 26 | var2 = list(type = "Poisson", paramStr = "") 27 | ) 28 | 29 | algo <- list( 30 | nClass = 2, 31 | nInd = 100, 32 | nbBurnInIter = 100, 33 | nbIter = 100, 34 | nbGibbsBurnInIter = 100, 35 | nbGibbsIter = 100, 36 | nInitPerClass = 3, 37 | nSemTry = 20, 38 | confidenceLevel = 0.95, 39 | ratioStableCriterion = 0.95, 40 | nStableCriterion = 10, 41 | mode = "learn" 42 | ) 43 | 44 | resLearn <-RMixtCompIO::rmcMultiRun(algo, dataLearn, model, nRun = 3) 45 | 46 | summary(resLearn) 47 | } 48 | 49 | } 50 | \seealso{ 51 | \code{mixtCompLearn} \code{\link{print.MixtComp}} 52 | } 53 | \author{ 54 | Quentin Grimonprez 55 | } 56 | -------------------------------------------------------------------------------- /RMixtCompUtilities/tests/testthat.R: -------------------------------------------------------------------------------- 1 | # MixtComp version 4 - july 2019 2 | # Copyright (C) Inria - Université de Lille - CNRS 3 | 4 | # This program is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU Affero General Public License as 6 | # published by the Free Software Foundation, either version 3 of the 7 | # License, or (at your option) any later version. 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Affero General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Affero General Public License 14 | # along with this program. If not, see 15 | 16 | 17 | library(testthat) 18 | library(RMixtCompUtilities) 19 | 20 | test_check("RMixtCompUtilities") 21 | -------------------------------------------------------------------------------- /ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Script to be launched on a continuous integration machine 4 | 5 | cd MixtComp 6 | ./clean.sh 7 | ./build.sh Coverage 8 | cd build/ && MC_DETERMINISTIC=T make MixtComp_coverage && cd .. 9 | ./valgrindRun.sh 10 | cd ../JMixtComp 11 | ./clean.sh 12 | ./build.sh Debug 13 | cd build/ && make runUtestJMC && cd .. 14 | ./valgrindRun.sh 15 | cd ../pyMixtComp 16 | ./clean.sh 17 | ./build.sh build 18 | ./utest.sh 19 | cd ../RMixtCompIO 20 | make clean 21 | make updateLib 22 | make all 23 | Rscript -e 'library(methods); library(devtools); options(testthat.output_file = "RMCIOtest.xml"); test(".", reporter = JunitReporter)' 24 | cd ../RMixtCompUtilities 25 | R CMD INSTALL --no-multiarch --with-keep.source . 26 | Rscript -e 'library(methods); library(devtools); options(testthat.output_file = "RMCUttest.xml"); test(".", reporter = JunitReporter)' 27 | cd ../RMixtComp 28 | R CMD INSTALL --no-multiarch --with-keep.source . 29 | Rscript -e 'library(methods); library(devtools); options(testthat.output_file = "RMCtest.xml"); test(".", reporter = JunitReporter)' 30 | cd ../RJMixtComp 31 | ./update.sh 32 | R CMD INSTALL --no-multiarch --with-keep.source . 33 | Rscript -e 'library(methods); library(devtools); options(testthat.output_file = "RJMCtest.xml"); test(".", reporter = JunitReporter)' 34 | # cd ../RMixtCompHier 35 | # R CMD INSTALL --no-multiarch --with-keep.source . 36 | # Rscript -e 'library(methods); library(devtools); options(testthat.output_file = "RMCHiertest.xml"); test(".", reporter = JunitReporter)' 37 | -------------------------------------------------------------------------------- /graphArchitecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/graphArchitecture.png -------------------------------------------------------------------------------- /graphArchitecture.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/graphArchitecture.xcf -------------------------------------------------------------------------------- /mcCleanUpdate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Script to be launched on a machine for a user that will run RMixtComp 4 | 5 | cd RMixtComp 6 | git pull 7 | make clean 8 | make updatelib 9 | make all 10 | -------------------------------------------------------------------------------- /pyMixtComp/README.md: -------------------------------------------------------------------------------- 1 | # pyMixtComp 2 | 3 | *pyMixtCompBridge* is a C++ library containing the minimal interface of MixtComp for python. 4 | The *pyMixtComp* python package is the equivalent of RMixtComp. 5 | 6 | ## Requirements 7 | 8 | *pyMixtCompBridge* requires python3.8 and the *numpy* package. See [MixtComp's README](../MixtComp/README.md) for MixtComp's requirements. 9 | 10 | ``` bash 11 | sudo apt install python3-pip 12 | pip3 install numpy 13 | ``` 14 | 15 | It requires [Boost.Python](https://www.boost.org/doc/libs/1_72_0/libs/python/doc/html/index.html) library. 16 | 17 | ``` bash 18 | brew install boost-python3 19 | ``` 20 | 21 | ## Compile PyMixtComp 22 | 23 | Run `./build.sh` to compile MixtComp in Debug mode. Run `./build.sh Release` for compiling in Release mode. 24 | The resulting files are located in the build folder. 25 | Run `./utest.sh` to run unit tests. 26 | To clean the build folder, run `./clean.sh`. 27 | 28 | ## Python library 29 | 30 | After compiling, *pyMixtCompBridge* library can be found at the following location: `build/lib/pyMixtCompBridge.so`. 31 | 32 | ## Python package 33 | 34 | The python package is located in the [python](./python) folder. 35 | See the [README](./python/README.md) to install the package. 36 | -------------------------------------------------------------------------------- /pyMixtComp/build.sh: -------------------------------------------------------------------------------- 1 | mkdir -p build 2 | cd build 3 | if [ $# -eq 0 ] 4 | then 5 | cmake -DCMAKE_BUILD_TYPE=Debug ../src 6 | else 7 | cmake -DCMAKE_BUILD_TYPE=$1 ../src 8 | fi 9 | cmake --build . 10 | -------------------------------------------------------------------------------- /pyMixtComp/clean.sh: -------------------------------------------------------------------------------- 1 | find ./build ! -name '.' -type f -exec rm -f {} + 2 | find ./build ! -name '.' -type d -exec rm -r -f {} + 3 | -------------------------------------------------------------------------------- /pyMixtComp/python/README.md: -------------------------------------------------------------------------------- 1 | # pyMixtComp 2 | 3 | Python package of the C++ library MixtComp. 4 | Mixture models with heterogeneous data sets and partially missing data management. 5 | 6 | ## Installation 7 | 8 | First, compile the C++ library: 9 | 10 | ``` bash 11 | ./build.sh 12 | ``` 13 | 14 | The python package uses [poetry](https://python-poetry.org/docs/#installation) as build system. 15 | Install pyMixtComp using pip: 16 | 17 | ``` bash 18 | pip3 install . 19 | ``` 20 | 21 | ## Run tests 22 | 23 | Install pytest: 24 | 25 | ``` bash 26 | pip3 install pytest 27 | ``` 28 | 29 | Run tests: 30 | 31 | ``` bash 32 | pytest . 33 | ``` 34 | 35 | ## Examples 36 | 37 | ``` python 38 | import matplotlib.pyplot as plt 39 | from pyMixtComp import MixtComp 40 | from pyMixtComp.data import load_prostate 41 | data, model = load_prostate() 42 | data.head() 43 | ``` 44 | 45 | Prostate data are mixed data (real and categorical). All variables are stored as object, "?" indicates missing values. 46 | And the model dict indicates which model used for every variable. 47 | 48 | ``` python 49 | model 50 | mod = MixtComp(n_components=2, n_init=5) 51 | mod.fit(data[:-50], model) 52 | ``` 53 | 54 | Plot the discriminative power of variables to find the variables that participate the most at the clustering task. 55 | 56 | ``` python 57 | mod.plot_discriminative_power_variable() 58 | plt.show() 59 | ``` 60 | 61 | SG and AP are the most discriminant variables. 62 | 63 | ``` python 64 | mod.get_param("SG") 65 | ``` 66 | 67 | Predict the cluster of the 50 last data 68 | 69 | ``` python 70 | mod.predict(data[-50:], model) 71 | ``` 72 | -------------------------------------------------------------------------------- /pyMixtComp/python/build.sh: -------------------------------------------------------------------------------- 1 | cd .. && ./build.sh Release && cd python 2 | cp ../build/lib/pyMixtCompBridge.so pyMixtComp/pyMixtCompBridge.so -------------------------------------------------------------------------------- /pyMixtComp/python/pyMixtComp/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | import importlib.metadata 3 | 4 | from . import data, plot, utils 5 | from .MixtComp import MixtComp 6 | 7 | try: 8 | __version__ = importlib.metadata.version("pyMixtComp") 9 | except importlib.metadata.PackageNotFoundError: 10 | __version__ = "Not installed" 11 | -------------------------------------------------------------------------------- /pyMixtComp/python/pyMixtComp/bridge/bridge.py: -------------------------------------------------------------------------------- 1 | """ 2 | Run the c++ executable with python parameters 3 | """ 4 | from functools import partial 5 | from multiprocessing import Pool 6 | 7 | import numpy as np 8 | 9 | from .. import pyMixtCompBridge 10 | 11 | 12 | def run_pmc(i, algo, data, model, param): 13 | return pyMixtCompBridge.pmc(algo, data, model, param) 14 | 15 | 16 | def multi_run_pmc_pool(algo, data, model, param, n_run, n_core): 17 | """Run pmc multiple times 18 | 19 | The best model according to the observed loglikelihood is kept 20 | 21 | Parameters 22 | ---------- 23 | algo : dict 24 | Algorithm parameters 25 | data : dict 26 | Each key corresponds to a variable with data as a list of str 27 | model : dict 28 | Model used for each parameters 29 | param : dict 30 | dict with learnt model 31 | n_run : int 32 | Number of runs 33 | n_core : int 34 | Number of cores for multiprocessing 35 | """ 36 | p = Pool(n_core) 37 | run_pmc_i = partial(run_pmc, algo=algo, data=data, model=model, param=param) 38 | out = p.map(run_pmc_i, range(n_run)) 39 | 40 | loglikelihood = np.full((n_run,), -np.inf) 41 | for i in range(n_run): 42 | if "warnLog" not in out[i].keys(): 43 | loglikelihood[i] = out[i]["mixture"]["lnObservedLikelihood"] 44 | 45 | ind_max = np.argmax(loglikelihood) 46 | 47 | return out[ind_max] 48 | -------------------------------------------------------------------------------- /pyMixtComp/python/pyMixtComp/data/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | from .data import load_canadian_weather, load_iris, load_prostate, load_simulated_data 3 | -------------------------------------------------------------------------------- /pyMixtComp/python/pyMixtComp/plot/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | from .barplot import ( 3 | compute_discriminative_power_class, 4 | compute_discriminative_power_variable, 5 | plot_discriminative_power_class, 6 | plot_discriminative_power_variable, 7 | plot_proportion, 8 | ) 9 | from .heatmap import ( 10 | compute_class_similarity, 11 | compute_variable_similarity, 12 | plot_class_similarity, 13 | plot_tik, 14 | plot_variable_similarity, 15 | ) 16 | from .univariate_boxplot import plot_data 17 | from .univariate_distribution import plot_data_CI 18 | -------------------------------------------------------------------------------- /pyMixtComp/python/pyMixtComp/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | from .convert import convert_functional, create_functional, refactor_categorical 3 | from .criterion import ( 4 | compute_class_similarity, 5 | compute_discriminative_power_class, 6 | compute_discriminative_power_variable, 7 | compute_variable_similarity, 8 | ) 9 | from .getter import get_param, get_partition, get_tik 10 | from .sample import sample 11 | -------------------------------------------------------------------------------- /pyMixtComp/python/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "pyMixtComp" 3 | version = "0.1.3" 4 | description = "Mixture models with heterogeneous data sets and partially missing data management." 5 | authors = [ 6 | "Vincent Kubicki", 7 | "Christophe Biernacki", 8 | "Quentin Grimonprez ", 9 | "Matthieu Marbac-Lourdelle", 10 | "Étienne Goffinet", 11 | "Serge Iovleff", 12 | ] 13 | 14 | maintainers = [ 15 | "Quentin Grimonprez ", 16 | ] 17 | 18 | include = ["pyMixtComp/pyMixtCompBridge.so"] 19 | 20 | packages = [ 21 | {include = "pyMixtComp"} 22 | ] 23 | 24 | keywords=["clustering", "mixture model", "heterogeneous", "missing data"] 25 | 26 | readme = "README.md" 27 | 28 | # see https://pypi.org/classifiers/ 29 | classifiers = [ 30 | "Programming Language :: Python :: 3", 31 | "Operating System :: OS Independent", 32 | "Programming Language :: C++", 33 | "Programming Language :: Python", 34 | "Topic :: Scientific/Engineering :: Artificial Intelligence", 35 | ] 36 | 37 | repository = "https://github.com/modal-inria/MixtComp" 38 | 39 | [tool.poetry.dependencies] 40 | python = ">=3.8,<3.12" 41 | scikit-learn = "^1.0" 42 | seaborn = ">0.11.2,<1" 43 | pandas = ">=1.3,<3" 44 | 45 | [tool.poetry.group.test.dependencies] 46 | pytest = "^7.0" 47 | 48 | [tool.poetry.group.dev.dependencies] 49 | jupyter = "^1.0.0" 50 | 51 | [build-system] 52 | requires = ["poetry-core>=1.2.0"] 53 | build-backend = "poetry.core.masonry.api" -------------------------------------------------------------------------------- /pyMixtComp/python/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/pyMixtComp/python/tests/__init__.py -------------------------------------------------------------------------------- /pyMixtComp/python/tests/mixtcomp_output.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/pyMixtComp/python/tests/mixtcomp_output.pickle -------------------------------------------------------------------------------- /pyMixtComp/python/tests/mixtcomp_output_full.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/pyMixtComp/python/tests/mixtcomp_output_full.pickle -------------------------------------------------------------------------------- /pyMixtComp/python/tests/mixtcomp_output_functional.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/pyMixtComp/python/tests/mixtcomp_output_functional.pickle -------------------------------------------------------------------------------- /pyMixtComp/python/tests/mixtcomp_output_functional_diff_time.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/modal-inria/MixtComp/096093723b823b22d90462791cba602265230b53/pyMixtComp/python/tests/mixtcomp_output_functional_diff_time.pickle -------------------------------------------------------------------------------- /pyMixtComp/python/tests/test_data.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import pandas as pd 4 | from pyMixtComp.data import load_canadian_weather, load_iris, load_prostate, load_simulated_data 5 | 6 | 7 | class TestData(unittest.TestCase): 8 | def test_load_prostate(self): 9 | data, model = load_prostate() 10 | 11 | self.assertIsInstance(data, pd.DataFrame) 12 | self.assertEqual(data.shape, (506, 12)) 13 | self.assertEqual(len(model), 12) 14 | self.assertListEqual(list(model.keys()), list(data.columns)) 15 | 16 | def test_load_canadian_weather(self): 17 | data, model = load_canadian_weather() 18 | 19 | self.assertIsInstance(data, pd.DataFrame) 20 | self.assertEqual(data.shape, (35, 2)) 21 | self.assertEqual(len(model), 2) 22 | self.assertListEqual(list(model.keys()), list(data.columns)) 23 | 24 | def test_load_simulated_data(self): 25 | data, model = load_simulated_data() 26 | 27 | self.assertIsInstance(data, pd.DataFrame) 28 | self.assertEqual(data.shape, (200, 9)) 29 | self.assertEqual(len(model), 8) 30 | self.assertListEqual(list(model.keys()), list(data.columns[1:])) 31 | 32 | def test_load_iris(self): 33 | data, model = load_iris() 34 | 35 | self.assertIsInstance(data, pd.DataFrame) 36 | self.assertEqual(data.shape, (150, 5)) 37 | self.assertEqual(len(model), 4) 38 | self.assertListEqual(list(model.keys()), list(data.columns[:-1])) 39 | self.assertListEqual(list(data.dtypes), [float, float, float, float, object]) 40 | 41 | 42 | if __name__ == "__main__": 43 | unittest.main() 44 | -------------------------------------------------------------------------------- /pyMixtComp/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.8) 3 | 4 | project(pyMixtComp) 5 | 6 | # C++ standard 7 | set(CMAKE_CXX_STANDARD 17) 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 9 | 10 | # boost 11 | find_package(Boost 1.58 COMPONENTS python numpy REQUIRED) 12 | include_directories(${Boost_INCLUDE_DIRS}) 13 | 14 | # python 15 | find_package(PythonInterp 3.6) 16 | find_package(PythonLibs 3.6 REQUIRED) 17 | include_directories(${PYTHON_INCLUDE_DIRS}) 18 | 19 | 20 | # Compile MixtComp 21 | add_compile_options("-DMINMODALITY=0") 22 | add_subdirectory(../../MixtComp/src MixtComp) 23 | 24 | # add MixtComp's include directories and definitions 25 | include_directories(${MixtComp_INCLUDE_DIRS}) 26 | add_definitions(${MixtComp_DEFINITIONS}) 27 | 28 | # add pyMixtComp include 29 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) # to enable PIC on platforms that need it 30 | include_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib/") 31 | 32 | # add python interface code 33 | add_subdirectory(lib) 34 | 35 | # add test 36 | add_subdirectory(utest EXCLUDE_FROM_ALL) 37 | -------------------------------------------------------------------------------- /pyMixtComp/src/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_library(pyMixtCompLib 3 | pmc.cpp 4 | pmc.h 5 | PyGraph.h 6 | PyGraph.cpp 7 | pythonIO.h 8 | translateCPPToPython.h 9 | translatePythonToCPP.h) 10 | 11 | 12 | # Define the wrapper library that wraps our library 13 | add_library(pyMixtCompBridge SHARED pyMixtComp.cpp) 14 | 15 | target_link_libraries(pyMixtCompBridge 16 | pyMixtCompLib 17 | MixtComp 18 | ${Boost_LIBRARIES} 19 | ${PYTHON_LIBRARIES}) 20 | 21 | # don't prepend wrapper library name with lib 22 | set_target_properties(pyMixtCompBridge PROPERTIES PREFIX "" SUFFIX ".so") 23 | 24 | -------------------------------------------------------------------------------- /pyMixtComp/src/lib/pmc.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: June 13, 2019 20 | * Author: Quentin Grimonprez 21 | **/ 22 | 23 | #ifndef SRC_PMC_H_ 24 | #define SRC_PMC_H_ 25 | 26 | #include 27 | 28 | boost::python::dict pmc(boost::python::dict algoPy, boost::python::dict dataPy, boost::python::dict descPy, boost::python::dict resLearnPy); 29 | 30 | #endif /* SRC_PMC_H_ */ 31 | -------------------------------------------------------------------------------- /pyMixtComp/src/lib/pyMixtComp.cpp: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: June 21, 2019 20 | * Authors: Quentin Grimonprez 21 | **/ 22 | 23 | #include 24 | #include 25 | #include "pmc.h" 26 | 27 | 28 | 29 | BOOST_PYTHON_MODULE(pyMixtCompBridge) 30 | { 31 | Py_Initialize(); 32 | boost::python::numpy::initialize(); 33 | boost::python::def("pmc", pmc); 34 | } 35 | -------------------------------------------------------------------------------- /pyMixtComp/src/lib/pythonIO.h: -------------------------------------------------------------------------------- 1 | /* MixtComp version 4 - july 2019 2 | * Copyright (C) Inria - Université de Lille - CNRS*/ 3 | 4 | /* This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as 6 | * published by the Free Software Foundation, either version 3 of the 7 | * License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Affero General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Affero General Public License 14 | * along with this program. If not, see 15 | **/ 16 | 17 | /* 18 | * Project: MixtComp 19 | * Created on: June 28, 2019 20 | * Authors: Quentin GRIMONPREZ 21 | **/ 22 | 23 | #ifndef PYTHON_PYTHONIO_H 24 | #define PYTHON_PYTHONIO_H 25 | 26 | #include "PyGraph.h" 27 | #include "translateCPPToPython.h" 28 | #include "translatePythonToCPP.h" 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /pyMixtComp/src/utest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # google test project is built by MixtComp 2 | 3 | add_executable(runUtestPy 4 | UTestPyGraph.cpp 5 | ) 6 | 7 | target_link_libraries(runUtestPy 8 | gtest_main 9 | pyMixtCompLib 10 | MixtComp 11 | ${Boost_LIBRARIES} 12 | ${PYTHON_LIBRARIES} 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /pyMixtComp/utest.sh: -------------------------------------------------------------------------------- 1 | cd build && make runUtestPy && cd .. 2 | MC_DETERMINISTIC=T build/utest/runUtestPy --gtest_output=xml:reportPy.xml 3 | --------------------------------------------------------------------------------