Building a classifier based on Gaussian Mixture Models
Let's build a classifier based on a Gaussian Mixture Model. Create a new Python file and import the following packages:
import numpy as np import matplotlib.pyplot as plt from matplotlib import patches from sklearn import datasets from sklearn.mixture import GMM from sklearn.cross_validation import StratifiedKFold
Let's use the iris dataset available in scikit-learn for analysis:
# Load the iris dataset iris = datasets.load_iris()
Split the dataset into training and testing using an 80/20 split. The n_folds
parameter specifies the number of subsets you'll obtain. We are using a value of 5, which means the dataset will be split into five parts. We will use four parts for training and one part for testing, which gives a split of 80/20:
# Split dataset into training and testing (80/20 split) indices = StratifiedKFold(iris.target, n_folds=5)
Extract the training data:
# Take...