# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Exercise 18
#
#
# For this homework we consider a set of observations on a number of red and white wine varieties involving their chemical properties and ranking by tasters. Wine industry shows a recent growth spurt as social drinking is on the rise. The price of wine depends on a rather abstract concept of wine appreciation by wine tasters, opinion among whom may have a high degree of variability. Pricing of wine depends on such a volatile factor to some extent. Another key factor in wine certification and quality assessment is physicochemical tests which are laboratory-based and takes into account factors like acidity, pH level, presence of sugar and other chemical properties. For the wine market, it would be of interest if human quality of tasting can be related to the chemical properties of wine so that certification and quality assessment and assurance process is more controlled.
#
# Two datasets are available of which one dataset is on red wine and have 1599 different varieties and the other is on white wine and have 4898 varieties. All wines are produced in a particular area of Portugal. Data are collected on 12 different properties of the wines one of which is Quality, based on sensory data, and the rest are on chemical properties of the wines including density, acidity, alcohol content etc. All chemical properties of wines are continuous variables. Quality is an ordinal variable with possible ranking from 1 (worst) to 10 (best). Each variety of wine is tasted by three independent tasters and the final rank assigned is the median rank given by the tasters.
#
# A predictive model developed on this data is expected to provide guidance to vineyards regarding quality and price expected on their produce without heavy reliance on volatility of wine tasters.

import pandas as pd
import numpy as np

import zipfile
with zipfile.ZipFile('wine_data.zip', 'r') as z:
    f = z.open('Wine_data_red.csv')
    data_r = pd.io.parsers.read_table(f, sep=',')
    f = z.open('Wine_data_white.csv')
    data_w = pd.io.parsers.read_table(f, sep=',')

data = data_w.assign(type = 'white')

data = data.append(data_r.assign(type = 'red'), ignore_index=True)
data.sample(5)

# # Exercice 18.1
#
# Show the frecuency table of the quality by type of wine



# # Exercice 18.2 (2 points)
#
# * Standarized the features (not the quality)
# * Create a binary target for each type of wine
# * Create two Linear SVM's for the white and red wines, repectively.
#



# # Exercice 18.3 (2 points)
#
# Test the two SVM's using the different kernels (‘poly’, ‘rbf’, ‘sigmoid’)
#



# # Exercice 18.4 (2 points)
#
# Using the best SVM find the parameters that gives the best performance
#
# 'C': [0.1, 1, 10, 100, 1000], 'gamma': [0.01, 0.001, 0.0001]



# # Exercice 18.5
#
# Compare the results with other methods



StarcoderdataJupyterScriptsDedupFiltered