Code Monkey home page Code Monkey logo

otmixmod's Issues

There is no method to get the list of valid covariance models

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)

otmixmod crashes

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 doc is not in Sphinx format

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.