{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "gmm",
              "annotation": ":class:`sklearn.mixture.GaussianMixture`",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The estimated GMM object, which contains the necessary parameters needed to compute the Fisher vector."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Estimate a Gaussian mixture model (GMM) given a set of descriptors and number of modes (i.e. Gaussians). This function is essentially a wrapper around the scikit-learn implementation of GMM, namely the "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "sklearn.mixture.GaussianMixture",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "sklearn",
                "version": "*",
                "kind": "api",
                "path": "sklearn.mixture._gaussian_mixture:GaussianMixture"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " class."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "descriptors",
              "annotation": "ndarray of shape (N, M) or list of (tuple[int, int])",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "List of NumPy arrays, or a single NumPy array, of the descriptors used to estimate the GMM. The reason a list of NumPy arrays is permissible is because often when using a Fisher vector encoding, descriptors/vectors are computed separately for each sample/image in the dataset, such as SIFT vectors for each image. If a list if passed in, then each element must be a NumPy array in which the number of rows may differ (e.g. different number of SIFT vector for each image), but the number of columns for each must be the same (i.e. the dimensionality must be the same)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "n_modes",
              "annotation": "int",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "The number of modes/Gaussians to estimate during the GMM estimate."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "gm_args",
              "annotation": "dict",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Keyword arguments that can be passed into the underlying scikit-learn "
                    },
                    {
                      "__type": "CrossRef",
                      "__tag": 4002,
                      "value": "sklearn.mixture.GaussianMixture",
                      "reference": {
                        "__type": "RefInfo",
                        "__tag": 4000,
                        "module": "sklearn",
                        "version": "*",
                        "kind": "api",
                        "path": "sklearn.mixture._gaussian_mixture:GaussianMixture"
                      },
                      "kind": "module"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": " class."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Due to the nature of the Fisher vector, the only enforced parameter of the underlying scikit-learn class is the covariance_type, which must be 'diag'."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "There is no simple way to know what value to use for "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "n_modes"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " a-priori. Typically, the value is usually one of "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "{16, 32, 64, 128}"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". One may train a few GMMs and choose the one that maximises the log probability of the GMM, or choose "
            },
            {
              "__type": "ParamRef",
              "__tag": 4071,
              "name": "n_modes"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " such that the downstream classifier trained on the resultant Fisher vectors has maximal performance."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Returns",
    "Yields",
    "Receives",
    "Raises",
    "Warns",
    "Other Parameters",
    "Attributes",
    "Methods",
    "Notes",
    "Warnings"
  ],
  "item_file": "/dev/scikit-image/src/skimage/feature/_fisher_vector.py",
  "item_line": 40,
  "item_type": "function",
  "aliases": [
    "skimage.feature.learn_gmm"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "from skimage.feature import fisher_vector\nrng = np.random.Generator(np.random.PCG64())\nsift_for_images = [rng.standard_normal((10, 128)) for _ in range(10)]\nnum_modes = 16\ngmm = learn_gmm(sift_for_images, n_modes=num_modes)\n",
        "execution_status": "success"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "descriptors",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "n_modes",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "32"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "gm_args",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "KEYWORD_ONLY",
        "default": "None"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "learn_gmm"
  },
  "references": [
    ".. [1] https://scikit-learn.org/stable/modules/generated/sklearn.mixture.GaussianMixture.html"
  ],
  "qa": "skimage.feature._fisher_vector:learn_gmm",
  "arbitrary": [],
  "local_refs": [
    "descriptors",
    "gm_args",
    "gmm",
    "n_modes"
  ]
}