top of page
  • Writer's picturebhavesh wadibhasme

Wine Variety Classification

!pip install pycaret
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import warnings
df  = pd.read_csv("/content/Wine.csv")

Here the first column is the target column and the rest of the others are independent variables. Looking at the dataset it looks like all the variables are numeric. Let's do that check in the next code block.


Looking at the above result it looks like our guessing was correct. All the independant varibales are numeric. Now let's check out the second criterion of missing values. In the next block of code, we will check whether there are any missing values in the dataset.


The above output shows that there are no missing values in the dataset. As there are no missing values in the given dataset, missing values treatment is not required here. Let's move to our next check of imbalance testing. In the imbalance check, we will test whether our dataset carrying any imbalance or not. The linear machine learning model is sensitive to imbalanced datasets and performs poorly on such datasets. So to test class imbalance we will be using "countplot" from the seaborn library.


Looking at the above graph we can conclude that there is no such imbalance in the dataset. All three populations are not exactly the same but it is okay according to the definition of imbalance dataset in machine learning.

sns.pairplot(df.iloc[:,0:5],hue = '1')

Looking at the above pair plot we can conclude that the is a difference in the distribution in examples that belongs to different classes. It shows that for many of the feature different class labels examples centroids are differing from each other. Which is a sign of having variation/differentiation in character between inter-class label examples.

#-------Lets_build_pycaret_model_to_get_idea_about_ML_model------------from pycaret.classification import *
model = setup(df,target = "1")

target = df['1']
df = df.drop('1',axis=1)
#-----------Split_entire_dataset_into_train_and_validation_sets--------from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test = train_test_split(df,target,test_size = 0.20,random_state = 42)
from sklearn.ensemble import ExtraTreesClassifier
model = ExtraTreesClassifier(verbose=1),y_train)
predictions = model.predict(X_test)
from sklearn.metrics import classification_report

43 views0 comments

Recent Posts

See All


bottom of page