openturns / otmixmod Goto Github PK
View Code? Open in Web Editor NEWMixMod module
Home Page: http://openturns.github.io/otmixmod/master/
License: GNU General Public License v3.0
MixMod module
Home Page: http://openturns.github.io/otmixmod/master/
License: GNU General Public License v3.0
There is no method to get the list of valid covariance models. This would be handy to experiment with various models.
Here is a workaround.
import otmixmod
def otmixmod_GetValidCovarianceModels():
listOfValidModels = [
"Gaussian_p_L_I",
"Gaussian_p_Lk_I",
"Gaussian_p_L_B",
"Gaussian_p_Lk_B",
"Gaussian_p_L_Bk",
"Gaussian_p_Lk_Bk",
"Gaussian_p_L_C",
"Gaussian_p_Lk_C",
"Gaussian_p_L_D_Ak_D",
"Gaussian_p_Lk_D_Ak_D",
"Gaussian_p_L_Dk_A_Dk",
"Gaussian_p_Lk_Dk_A_Dk",
"Gaussian_p_L_Ck",
"Gaussian_p_Lk_Ck",
"Gaussian_pk_L_I",
"Gaussian_pk_Lk_I",
"Gaussian_pk_L_B",
"Gaussian_pk_Lk_B",
"Gaussian_pk_L_Bk",
"Gaussian_pk_Lk_Bk",
"Gaussian_pk_L_C",
"Gaussian_pk_Lk_C",
"Gaussian_pk_L_D_Ak_D",
"Gaussian_pk_Lk_D_Ak_D",
"Gaussian_pk_L_Dk_A_Dk",
"Gaussian_pk_Lk_Dk_A_Dk",
"Gaussian_pk_L_Ck",
"Gaussian_pk_Lk_Ck"
]
return listOfValidModels
# %%
listOfValidModels = otmixmod_GetValidCovarianceModels()
numberOfClasses = 2
for covarianceModel in listOfValidModels:
factory = otmixmod.MixtureFactory(numberOfClasses, covarianceModel)
print(f"Build with covariance model = {covarianceModel}")
mixture, labels, logLikelihood = factory.buildAsMixture(sample)
In the next script, I make a loop over the different covariance models in Mixmod. This makes the kernel crash.
# %%
import openturns as ot
import otmixmod
# %%
print(ot.__version__)
print(otmixmod.__version__)
# %%
ot.RandomGenerator.SetSeed(0)
# %%
def generateData(sampleSize):
# Gaussian 1
mu1 = ot.Point([-2.0, 2.0])
sigma1 = ot.Point(2, 1.0)
correlation1 = ot.CorrelationMatrix(2)
correlation1[0, 1] = 0.2
gaussian1 = ot.Normal(mu1, sigma1, correlation1)
# Gaussian 2
mu2 = ot.Point([2.0, -2.0])
sigma2 = ot.Point(2, 0.5)
correlation2 = ot.CorrelationMatrix(2)
correlation2[0, 1] = -0.5
gaussian2 = ot.Normal(mu2, sigma2, correlation2)
# Mixture
w1 = 1.0 / 3.0
w2 = 1.0 - w1
mixture = ot.Mixture([gaussian1, gaussian2], [w1, w2])
#
sample = mixture.getSample(sampleSize)
return mixture, sample
# %%
sampleSize = 200
mixture, sample = generateData(sampleSize)
print("True mixture:")
print(mixture)
# %%
listOfValidModels = [
"Gaussian_p_L_I"
"Gaussian_p_Lk_I"
]
numberOfClasses = 2
# %%
for covarianceModel in listOfValidModels:
factory = otmixmod.MixtureFactory(numberOfClasses, covarianceModel)
print(f"Build with covariance model = {covarianceModel}")
mixture, labels, logLikelihood = factory.buildAsMixture(sample)
print(mixture)
The message is:
The Kernel crashed while executing code in the the current cell or a previous cell.
Please review the code in the cell(s) to identify a possible cause of the failure.
Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info.
View Jupyter [log](command:jupyter.viewOutput) for further details.
This is with OT 1.21 and otmixmod 0.14. The test is on Linux. otmixmod was installed with Conda.
The current doc format is LaTeX, which is not the up-to-date format for the doc of OpenTURNS modules.
This might be performed as a "usual" doc work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.