gmm2.0.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Music-Classification-MedleyDB 作者: DeepeshAgarawal 项目源码 文件源码
def plot_model(model, data):
    """

    :param model: the GMM model
    :param data: the data set 2D
    :return:
    """
    delta = 0.025
    x = np.arange(0.0, 4, delta)
    y = np.arange(0.0, 4, delta)
    X, Y = np.meshgrid(x, y)
    z = np.zeros((np.size(x), np.size(y)))
    # sum of Gaussian
    plt.figure()
    for i in range(np.size(model)):
        ztemp = mlab.bivariate_normal(X, Y, np.sqrt(model['cov'][i][0, 0]), np.sqrt(model['cov'][i][1, 1]), model['mu'][i][0], model['mu'][i][1], model['cov'][i][0,1])
        plt.contour(X, Y, model['w'][i]*ztemp)
        z = np.add(z, ztemp)
    plt.scatter(data[0, :], data[1, :], s=5)
    plt.figure()
    plt.contour(X, Y, z*np.size(model))
    plt.scatter(data[0, :], data[1, :], s=5)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号