MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# How does Quadratic Discriminant Analysis work?

# How does Quadratic Discriminant Analysis work?

This recipe explains how Quadratic Discriminant Analysis work

Quadratic Discriminant Analysis is a classifier with a quadratic decision boundary, generated by fitting class conditional densities to the data and using Bayes’ rule. It fits a Gaussian density to each class.

So this recipe is a short example on how does Quadratic Discriminant Analysis work. Let's get started.

```
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis
```

Let's pause and look at these imports. We have exported train_test_split which helps in randomly breaking the datset in two parts. Here sklearn.dataset is used to import one classification based model dataset. Also, we have exported QuadraticDiscriminantAnalysis to build our model.

```
X,y=load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
```

Here, we have used load_iris function to import our dataset in two list form (X and y) and therefore kept return_X_y to be True. Further with have broken down the dataset into 2 parts, train and test with ratio 3:4.

Now our dataset is ready.

```
model = QuadraticDiscriminantAnalysis()
```

We have simply built a classification model with QuadraticDiscriminantAnalysis with default values.

```
model.fit(X_train, y_train)
y_pred= model.predict(X_test)
```

Here we have simply fit used fit function to fit our model on X_train and y_train. Now, we are predicting the values of X_test using our built model.

```
print(model.score(X_train,y_train))
print(model.score(X_test,y_test))
```

Here we have calculated accuracy score using score function for both our train and test set.

Once we run the above code snippet, we will see:

0.9910714285714286 0.9736842105263158

Clearly, the model built for the given datset is highly efficient on any unknown set. It might be best model to fit on iris Dataset.

In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

Given big data at taxi service (ride-hailing) i.e. OLA, you will learn multi-step time series forecasting and clustering with Mini-Batch K-means Algorithm on geospatial data to predict future ride requests for a particular region at a given time.

In this deep learning project, you will find similar images (lookalikes) using deep learning and locality sensitive hashing to find customers who are most likely to click on an ad.

In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

Use cluster analysis to identify the groups of characteristically similar schools in the College Scorecard dataset. Considerations: Clustering Algorithm Data Preparation How will you deal with missing values? Categorical variables? Feature intercorrelations? Feature normalization or scaling? Dimensionality reduction? Hyperparameters How will you set the parameters -- the algorithm's knobs and dials, so to speak -- in order to achieve valid and useful output? Interpretation Is it possible to explain what each cluster represents? Did you retain or prepare a set of features that enables a meaningful interpretation of the clusters? Do the compositions of the clusters seem to make sense? Validation How will you measure the validity of your clustering process? Which metrics will you use and how will you apply them?

In this time series project, you will build a model to predict the stock prices and identify the best time series forecasting model that gives reliable and authentic results for decision making.

In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.