text_plain_output_1.png
from sklearn.ensemble import RandomForestClassifier

import matplotlib.pyplot as plt

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

df = pd.read_csv('../input/red-wine-quality-cortez-et-al-2009/winequality-red.csv')

fig = plt.figure(figsize=(5,5))
sns.barplot(x='quality', y='volatile acidity', data=df)

figure = plt.figure(figsize=(10, 10))
correlation = df.corr()
sns.heatmap(correlation, annot=True)

df.quality.value_counts()

X = df.drop(columns='quality', axis=1)
y = df['quality'].apply(lambda x: 1 if x > 6 else 0).values

classifier = RandomForestClassifier()
classifier.fit(X_train, y_train)

def predict(X, model):
    X = np.array(X).reshape(1, -1)
    pred = model.predict(X)
    if pred == 1:
        return 'Good Wine Quality'
    else:
        return 'Bad Wine Quality'

predict(X_test.values[3], classifier)