Classification
Machine
learning technique, which it learns from a historical dataset that categories
in various ways to predict new observation based on the given inputs. There are
two types of data analysis used to predict future data trends such as
classification and prediction. Here we will use these techniques to clarify
various fruits and predict the best accuracy of them. Some example of
classification applications is mail checking (spam or not), credit card fraud
detection, speech recognition, and biometric identification.
Number of steps to be followed
1. Understand the dataset
2. Methods of showing data (Visualization)
3. Crete train and test teste set to generate accuracy.
1. Understanding the data
The fruits dataset is a multivariate dataset introduced by Mr. Iain Murray from Edinburgh University. It contains dozens of fruit measurements such as apple, orange, and lemon.
1.1 Shape of data
Let’s look, how many instances we
have at the dataset.
- import pandas as pd
- import matplotlib.pyplot as plt
- import seaborn as sns
- fruit=pd.read_csv('fruit.csv')
- #fruits shape
- print(fruit.shape)
Here,
the dataset contains 59 pieces of fruit with seven features.
1.2 Types of fruits and count
- #types of fruits
- print(fruit.groupby('fruit_names').size())
- sns.countplot(fruit['fruit_name'],label="Count")

1.3 count data features
In the data frame, each row contains
one piece of fruit which measured by four features.
- #preview data
- print(fruit.head(15))

1.4 Statistical distribution
The fruits numerical data points,
which can be measured by the mean, median and percentiles. If the data
distribution does not have the same scale so, we need to apply the scaling
techniques.
- #Describtion of Data
- print(fruit.describe())

2. Methods of showing data (Visualization)
Here, we will apply two types of
visualization techniques to determine the distribution of variables and their
correlations.
2.1 Boxplot
It figures out data distribution by boxplot graph.
- #Boxplot
- plt.figure(figsize=(15,10))
- plt.subplot(2,2,1)
- sns.boxplot(x='fruit_name',y='mass',data=fruit)
- plt.subplot(2,2,2)
- sns.boxplot(x='fruit_name',y='width',data=fruit)
- plt.subplot(2,2,3)
- sns.boxplot(x='fruit_name',y='height',data=fruit)
- plt.subplot(2,2,4)
- sns.boxplot(x='fruit_name',y='color_score',data=fruit)

2.2 Pair plot – scatter matrix
Each fruit data point represented
by different color plots to provides better and effective determination as well
as a correlation between them.
- #pairplot
- sns.pairplot(fruit,hue='fruit_name')

3. Create a train and test set to generate accuracy
3.1 Split dataset
Now, we will separate the data frame
in two parts such as train and test set.







Elavarasan RPosted Jan 23, 2020, 2:00 PM
Thank you C# corner for making the Article meaningful.