scieee Open visual document viewer

Application of machine learning to predict quality of Portuguese wine based on sensory preferences

Nascimento, Alsénvitor Campos Aires do

Abstract

Technology has been broadly used in the wine industry, from vineyards to purchases, improving means or understanding customers' preferences. Numerous companies are using machine learning solutions to leverage their business. Henceforth, the sensory properties of wines constitute a significant element to determine wine quality, that combined with the accuracy of predictive models attained by classification methods, could be helpful to support winemakers enhance their outcomes. This research proposes a supervised machine learning approach to predict the quality of Portuguese wines based on sensory characteristics such as acidity, intensity, sweetness, and tannin. Additionally, this study includes red and white wines, implements, and compare the effectiveness of three classification algorithms. The conclusions promote understanding the importance of the sensory characteristics that influence the wine quality throughout customers' perception.

Full text

i Applica ion o machine lea ning o p edic quali y o Po uguese wine based on senso y p e e ences Alsén i o Campos Ai es do Nascimen o Disse a ion p esen ed as pa ial equi emen o ob aining he Mas e ’s deg ee in In o ma ion Managemen ii NOVA In o ma ion Managemen School Ins i u o Supe io de Es a ís ica e Ges ão de In o mação Uni e sidade No a de Lisboa APPLICATION OF MACHINE LEARNING TO PREDICT QUALITY OF PORTUGUESE WINE BASED ON SENSORY PREFERENCES by Alsén i o Campos Ai es do Nascimen o Disse a ion p esen ed as pa ial equi emen o ob aining he Mas e ’s deg ee in In o ma ion Managemen , wi h a specializa ion in Business In elligence. Co Ad iso : P o . D . Mau o Cas elli Co Ad iso : P o . D . B uno Miguel Pin o Damásio No embe 2021 iii ACKNOWLEDGEMENTS P ima ily, I would like o mani es my hank ulness o NOVA In o ma ion Managemen School o he oppo uni y; all body o p o esso s a he Mas e 's Deg ee p og am in In o ma ion Managemen – hanks o he knowledge sha ing and guidance du ing he cou se. My g a i ude and ecogni ion o he hesis ad iso s: P o esso Mau o Cas elli, o he suppo and eedback always p omp ly p o ided; P o esso B uno Damásio, o he insigh s, conduc and a en ion in he p ocess. I am also g a e ul o my amily and iends' pa ience and suppo . Finally, I would like o gi e a special hanks o Gisela Ga cia ha du ing he ime a Academic Se ices, helped me wice wi h he equi ed documen a ion o he immig a ion au ho i y. i ABSTRACT Technology has been b oadly used in he wine indus y, om ineya ds o pu chases, imp o ing means o unde s anding cus ome s' p e e ences. Nume ous companies a e using machine lea ning solu ions o le e age hei business. Hence o h, he senso y p ope ies o wines cons i u e a signi ican elemen o de e mine wine quali y, ha combined wi h he accu acy o p edic i e models a ained by classi ica ion me hods, could be help ul o suppo winemake s enhance hei ou comes. This esea ch p oposes a supe ised machine lea ning app oach o p edic he quali y o Po uguese wines based on senso y cha ac e is ics such as acidi y, in ensi y, swee ness, and annin. Addi ionally, his s udy includes ed and whi e wines, implemen s, and compa e he e ec i eness o h ee classi ica ion algo i hms. The conclusions p omo e unde s anding he impo ance o he senso y cha ac e is ics ha in luence he wine quali y h oughou cus ome s' pe cep ion. KEYWORDS Machine Lea ning; Po uguese Wine; Senso y; Quali y; Consume pe cep ions RESUMO Tecnologia em sendo amplamen e emp egada na indús ia do inho. Desde melho ia em p ocessos de cul i o à comp eensão de me cado po meio da análise de p e e ência de consumido es. Tendo em is a à a ual dinâmica dos me cados, emp esas es ão g adualmen e a conside a soluções que implemen am concei os de ap endizagem de máquina e agam di e encial compe i i o pa a po encializa o negócio. Do a an e, p op iedades senso iais são impo an es elemen os pa a de e minação da qualidade do inho, que aliado à p ecisão ob ida po modelos p edi i os podem auxilia p odu o es de inho a melho a p odu os e esul ados. O p esen e es udo p opõe a elabo ação de modelos de ap endizado supe isionado, baseado em algo i mos de classi icação a im de p e e qualidade de inhos po ugueses a pa i de dados senso iais de e ados po consumido es como acidez, in ensidade, açúca e aninos. A pesquisa inclui inhos in os e b ancos; implemen a e compa a a e e i idade de ês algo i mos de classi icação. Não obs an e, o es udo pe mi e comp eende como dados senso iais o necidos po consumido es podem de e mina a qualidade de inhos, bem como pe cebe quais ca ac e ís icas con ibuem no p ocesso de a aliação. PALAVRAS-CHAVE Ap endizado de máquina; Vinho Po uguês; Senso ial; Qualidade; Pe ceções do consumido i INDEX 1. In oduc ion .................................................................................................................. 1 1.1. Backg ound and p oblem de ini ion ..................................................................... 1 1.2. S udy objec i es..................................................................................................... 3 1.3. S udy ele ance and impo ance .......................................................................... 3 2. Li e a u e e iew .......................................................................................................... 4 2.1. Wine....................................................................................................................... 4 2.1.1. Wine quali y and classi ica ion ....................................................................... 4 2.1.2. Wine senso y pe cep ion ............................................................................... 5 2.2. Po uguese wine .................................................................................................... 7 2.2.1. Po uguese wine ma ke ................................................................................ 8 2.3. Vi ino ..................................................................................................................... 8 2.4. Da a collec ion and o ganiza ion........................................................................... 9 2.5. Da a mining and modelling echniques ............................................................... 10 3. Me hodology .............................................................................................................. 13 3.1. Resea ch app oach and design............................................................................ 13 3.1.1. Da a ex ac ion and inges ion ...................................................................... 13 3.1.2. Da a p epa a ion and alida ion .................................................................. 14 3.1.3. Da a p ep ocessing and explo a ion ............................................................ 14 3.1.4. Model aining .............................................................................................. 14 3.1.5. Model analysis and alida ion ...................................................................... 15 4. Resul s and discussion ................................................................................................ 16 4.1. Da ase desc ip ion ............................................................................................. 16 4.1.1. E o s and anomalies .................................................................................... 18 4.1.2. Ini ial a iables selec ion .............................................................................. 19 4.2. Pa e ns on Po uguese wines ............................................................................ 20 4.2.1. Red and whi e wines .................................................................................... 20 4.3. Da a p ocessing and explo a o y analysis ........................................................... 23 4.3.1. Co ela ions and mul i a ia e analysis ......................................................... 23 4.3.2. Missing alues .............................................................................................. 25 4.3.3. Ou lie s ......................................................................................................... 26 4.3.4. Final a iables selec ion and a ge de ini ion ............................................. 29 4.4. Model building ..................................................................................................... 29 4.5. Model e alua ion................................................................................................. 30 ii 5. Conclusions ................................................................................................................. 35 6. Limi a ions and ecommenda ions o u u e wo ks ................................................. 36 7. Bibliog aphy ................................................................................................................ 37 iii LIST OF FIGURES Figu e 2.1 - Classi ica ion me ics o mula. .............................................................................. 11 Figu e 3.1 - Da a p ocessing wo k low. .................................................................................... 13 Figu e 3.2 - De ini ion o Logis ic Reg ession model. ............................................................... 14 Figu e 3.3 - Mul i-laye pe cep on. ......................................................................................... 15 Figu e 4.1 - Da ase 's s uc u e a e he i s a iables selec ion........................................... 19 Figu e 4.2 - Red and whi e wines quali y his og am. ............................................................... 20 Figu e 4.3 - Senso y cha ac e is ics his og am o ed and whi e wines. ................................ 21 Figu e 4.4 - Pe cen age o alcohol in ed and whi e wines. ..................................................... 21 Figu e 4.5 - Body, alcohol, and in ensi y in ed and whi e wines. ........................................... 22 Figu e 4.6 - P ice his o y o ed and whi e wines. .................................................................. 22 Figu e 4.7 - Red wine a ibu es co ela ion. ........................................................................... 23 Figu e 4.8 - Whi e wine a ibu es co ela ion. ....................................................................... 24 Figu e 4.9 - Quali y, in ensi y, and alcohol compa ison. ......................................................... 25 Figu e 4.10 - Co ela ion ma ix a e handling missing alues. .............................................. 26 Figu e 4.11 - Red wines be o e emo e ou lie s. ..................................................................... 26 Figu e 4.12 - Whi e wines be o e emo e ou lie s. ................................................................. 27 Figu e 4.13 - Red wines a e emo e ou lie s. ........................................................................ 28 Figu e 4.14 - Whi e wines a e emo e ou lie s. .................................................................... 29 Figu e 4.15 - Model accu acy sco ing o ed and whi e wines. .............................................. 30 Figu e 4.16 - ROC cu e om MLP Classi ie model o ed and whi e wines. ........................ 31 Figu e 4.17 - ROC cu e om andom o es and logis ic eg ession models. ........................ 32 Figu e 4.18 - Fea u es impo ance om logis ic eg ession model o ed and whi e wines. 33 Figu e 4.19 - Fea u es impo ance om Random Fo es model o ed and whi e wines. ..... 33 Figu e 4.20 - Pa ial dependence plo o alcohol in ed wines. .............................................. 34 Figu e 4.21 - Pa ial dependence plo o acidi y in whi e wines. ........................................... 34 ix LIST OF TABLES Table 2.1 - Gene al wine as ing amewo k (Jackson, 2017). ................................................... 6 Table 2.2 - Hedonic wine as ing amewo k (Jackson, 2017). .................................................. 7 Table 2.3 - Po uguese be e age ma ke . .................................................................................. 8 Table 2.4 - Vi ino's a ing sys em in compa ison o expe 's amewo k. ................................. 9 Table 4.1 - To al o wines in he da ase . ................................................................................. 16 Table 4.2 - Vi ino's wine a ibu es. ......................................................................................... 17 Table 4.3 - Vi ino's as e cha ac e is ics. ................................................................................. 18 Table 4.4 - Missing alues. ....................................................................................................... 25 Table 4.5 - Ou lie s alues. ....................................................................................................... 27 Table 4.6 - Handling ou lie s. ................................................................................................... 28 Table 4.7 - Model's sco ing pe o mance. ............................................................................... 30 Table 4.8 - Con usion ma ix om logis ic eg ession model. ................................................. 31 Table 4.9 - Classi ica ion me ics o low-quali y. .................................................................... 32 Table 4.10 - Classi ica ion me ics o high-quali y. ................................................................. 32 6       Appea ance - Sco e (maximum +/- 1) Colo (hue, dep h, cla i y) Sp i z F ag ance - Sco e (maximum 5) Gene al ea u es Du a ion, In ensi y, De elopmen , Va ie al Cha ac e F ag ance ▪ Be y F ui (Blackbe y, Blackcu an , G ape, Melon, Raspbe y, S awbe y) ▪ T ee F ui (Apple, Ap ico , Banana, Che y, Gua a, G ape ui , Lemon, Li chi, Peach, Passion F ui , Quince) ▪ D y F ui (Fig, Raisin) ▪ Flo al (Camellia, Ci onella, I is, O ange blossom, Rose, Tulip, Viole ) ▪ Nu s (Almond, Hazelnu , Walnu ) ▪ Vege able (Aspa agus, Bee , Bell peppe , Canned G een beans, Hay, Oli es, Tea, Tobacco) ▪ Spice (Cinnamon, Clo es, Incense, Lico ice, Min , Peppe ) ▪ Roas ed (Ca amel, Co ee, Smoke, Toas ) ▪ O he (Bu e y, cheese, ciga box, honey, lea he , mush oom, oak, pine, phenolic, u le, anilla) Tas e Du a ion, De elopmen , In ensi y, Balance Speci ic Aspec s Swee ness, acidi y, as ingency, bi e ness, body, hea (alcohol le el), mellowness, sp i z (p ickling) Sco e (maximum 3) O e all assessmen Gene al quali y, po en ial, memo ableness Sco e (maximum 1) To al sco e (Maximum 10) Table 2.1 - Gene al wine as ing amewo k (Jackson, 2017). 7 Jackson (2017) p esen s ano he amewo k o measu e quali y in he wine as ing p ocess a he in- mou h sensa ion – he cha ac e iza ion o senses a e expe imen a ion. Table 2.2 demons a e he hedonis ic wine as e boa d. The in ensi y o colou ep esen s he s eng h o sensa ion; odou du a ion indica es he in e al o e which he wine e ol es o main ains i s senso y impac ; odou quali y alue he deg ee o which he ea u e e eals app op ia e and desi able. Sample numbe Wine ca ego y Excep ional Ve y Good Abo e a e age A e age Below A e age Poo Faul y Visual Cla i y In ensi y Odo (O honasal) Du a ion Quali y Fla o (Tas e, mou h- eel, e onasal odo ) In ensi y Du a ion Quali y Finish Du a ion Quali y Conclusion Table 2.2 - Hedonic wine as ing amewo k (Jackson, 2017). To summa ize, he au ho asse s ha he p ocess which makes wine g ea is sub le, in ol ing g apes, yeas , chemical and psychophysiological blending, dis inc i e aspec s ha impac ou senses (Jackson, 2017). 2.2. PORTUGUESE WINE Bloombe g has named Po ugal he wine coun y o 2021, a ibu ing i s ends o he quali y-p ice a io, as e and inexpensi e. I also highligh s he con ibu ions o digi al, a i icial in elligence inno a ion o expose wines om ex eme egions. Po ugal has ou een de ined wine-p oducing egions, including he con inen and islands, which sums a olume a e age o 6.359,395 li es consumed he las en yea s. As a esul , he amoun sold un il Oc obe 2020 in he local ma ke inc eased 46,8% o bo h ie s – DOP and IGP. The Po uguese wines a e classi ied in Denominação de O igem Con olada (DOC), Indicação Geog á ica P o egida (IGP), and Vinho de Mesa. The cu en a ea ep esen a ion ook place in he mid-1980 and was upda ed when he coun y joined Eu opean Union. The e a e 14 egions and 31 DOCs, including Madei a and Azo es. DOC is mo e igo ous and p esc ibes maximum yields, g ape a ie ies, minimum alcohol le els and ageing equi emen s; on he o he hand, IGP has mo e lexible ules. In he case o able wine, only he bo le and b and name a e allowed. Ins i u o da Vinha e do Vinho (IVV) is he o ganiza ion esponsible o con olling and p omo ing he sec o (Mayson, 2020). IVV claims o ha e a lis o 345 g ape a ie ies, whe e 194 a e ed o osé and 151 whi e. In addi ion, is egis e ed app oxima ely 250 indigenous species o g apes in he ins i u e. 8 2.2.1. Po uguese wine ma ke The O ganisa ion In e na ionale de la Vigne e du Vin epo s ha in 2020 Po ugal was among he la ges expo e s in he wo ld. The coun y also igu es a signi ican p oduc ion, se ing 2,6% global in 2019. In he Eu opean ma ke , Po ugal anks a i h posi ion. The Po uguese’s Sys em Classi ica ion o Economic Ac i i y – SICAE, o ganizes he p oduce s o consume goods and se ices acco ding o i s economics’ pu pose, including non-p o i and p o i - seeking businesses. I classi ies he ac i i ies in a a ie y o business domains o s a is ical ends. Fo example, in he be e age ma ke , he coun y pe o ms he ollowing scena io: CAE Economic p oduc ion En e p ises 11011 Água a den e 28 11013 Liquo s and o he spi i s d inks 151 11021 Common and o i ied wines 1.101 11022 Spa kling wine 25 11030 Cide and e men ed ui y d inks 18 11040 Ve mou h 11 11050 Bee 125 46341 Bo ling and wholesale ade o alcoholic d inks 2.116 46390 Re ail ade o alcoholic and non-acoholic d inks 656 01210 Cul i a ion o able and wine g apes 1.879 Table 2.3 - Po uguese be e age ma ke . The illus a ion demons a es he o al o business based on i s p ima y economic p oduc ion. I does no es ima e he numbe o p oduc s gene a ed o each manu ac u e . An en e p ise can pe o m in mul iple domains and hold seconda y ac i i ies. The e o e, a company could g ow g apes and no p oduce wine, jus as wo king exclusi ely in he bo ling p ocess and no ac ing on cul i a ion. 2.3. VIVINO Vi ino is a Danish online wine pla o m ha collec s and agg ega es da a om wine d inke s. The company main ains a websi e and a mobile applica ion ha enable use s o explo e and e alua e wine labels. I has o e 14 million lis ed wines o ganized by 3.378 wine egions and coun s app oxima ely 53 million use s. E e y wine en husias , expe o no , can make use o i . A e egis a ion, use s can scan labels, do e iews, a e wines, and join a communi y o gain o sha e knowledge. In addi ion, use s can sea ch o wine ypes, p ice ange, g apes, egions, coun ies, wine s yles, ood pai ing and a ings. Vi ino a ing wo ks di e en ly compa ed o well-known sco ing sys ems ha measu e wine poin s om 0 o 100. Ins ead, Vi ino uses i e s a s a ing sys em which can a e any wine om 1 o 5. Howe e , despi e being uncon en ional, he sys em connec s o he adi ional ones, as demons a ed in able 2.4. 9 Vi ino Ra ing 3.6 3.7 3.8 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 Robe Pa ke 88 89 89 90 90 91 92 92 93 93 94 96 97 Wine En husias 87 88 88 89 90 90 91 91 92 93 93 95 94 S ephen Tanze 89 89 90 90 90 91 91 91 92 92 93 94 95 An onio Galloni 89 89 90 90 91 92 92 92 93 94 94 95 96 Table 2.4 - Vi ino's a ing sys em in compa ison o expe 's amewo k. To sum up, Vi ino's a e age a e is 3.6. Hence, a 4.0 a ing co esponds o a 90 poin om he expe 's amewo k. The a ing's sys em e lec s Vi ino's communi y e alua ion. App oxima ely 20% o wo ldwide wines has expe e alua ion. On he o he hand, Vi ino ge s new wines and a ings daily, whe e cus ome s assess, inpu hei p e e ences and opinions ega ding he expe ienced p oduc s. In Po ugal, Vi ino ecognises 91 egions, 931.869 use s, 49.968 wines and 5.626 wine ies. The mos used g apes a e Tou iga nacional, Tin a Ro iz and Tou iga F anca. Howe e , 91 egions do no e lec he numbe o egions de ined by IVV. Acco ding o Mayson (2020), i has aken 250 yea s o Po ugal o es ablish a wo kable wine egions empla e. This ambiguous delimi a ion abou wine egions in he pas may jus i y how use s inpu he egions in Vi ino. 2.4. DATA COLLECTION AND ORGANIZATION Da a associa ed wi h a ious business domains is massi ely a ailable on he in e ne . I is published and can be collec ed in a a ie y o me hods. Acco ding o Somani and Deka (2018), da a can be accessible by Applica ion P og amming In e ace - API. I allows access o da a ac oss he web and, oge he wi h o he echniques, like Web sc aping, au oma ically ead a pa icula websi e and decode i s HTML elemen s o ex ac da a. Fo Mi chell (2018), Web sc aping is a me hod o ex ac isible in o ma ion om HTML on websi es. This me hod can be au oma ized by implemen ing a c awle o e ie e da a om a speci ic domain, pa sing and s o ing he a ge in o ma ion. Beau i ulSoup helps o ma and o ganize he messy by ixing bad HTML and p esen ing a e sable Py hon objec s. Py hon is an excellen language o machine lea ning due o i s clea syn ax, easy ex manipula ion, comp ehensi e applica ion, and ex ensi e de elopmen and documen a ion. Py hon also disposes o many scien i ic lib a ies such as SciPy and NumPy, allowing o do ec o and ma ix ope a ions (Ha ing on, 2012). The en y poin o a s eaming sys em is he collec ion o inges ion o da a. The da a low begins wi h da a inges ion om one o mo e sou ces, usually con ains ans o ma ions, and ends wi h he da a deli e y o display o consump ion (Psal is, 2017). 10 Malaska and Seidman (2018) s a ed ha he Ex ac , T ans o ma ion, and Loading p ocesses a e he ounda ion o pe o ming subsequen da a analysis, c ea ing epo s, and execu ing machine lea ning models o suppo ope a ional needs. Collec ing and analyzing da a is a signi ican ac i i y; SQL and ela ional da abases a e p ac ical ools o s anda dize da a access, es ablish scalabili y o e ha dwa e and ope a e da a manipula ion (Lino , 2016). The low quali y o he da a is a p oblem ha conce ns da a mining p ojec s. Da a cleansing is an al e na i e o add ess un eliable and co up ed da a in da a mining de elopmen (Wi en, 2011). 2.5. DATA MINING AND MODELLING TECHNIQUES La ose (2015) desc ibe da a mining as he p ocess o disco e ing unc ional pa e ns and ends in la ge da a se s, whe eas p edic i e analy ics implies ex ac ing in o ma ion om la ge da a se s o make p edic ions and es ima es abou u u e ou comes. Machine lea ning has many applica ions in e e yday li e; i is a sub ield o a i icial in elligence closely ela ed o applied ma hema ics and s a is ics. I is abou how a compu e can wo k mo e accu a ely as i collec s and lea ns om he da a. The mo e da a o expe ience he compu e ge s, he be e i becomes. Reg ession and classi ica ion a e wo essen ial echniques o de elop machine lea ning applica ions in da a science (Cielen, Meysman and Ali, 2016). Tan, S einbach, and Kuma (2014) conside ed ha p edic i e models' applica ions can be di ided in o wo g oups: classi ica ion models, in which he ou pu ep esen s he p obabili y o he beha iou occu ing and eg ession models ha p o ide a di ec es ima e. A classi ica ion echnique could be implemen ed by a decision ee, classi ie s, neu al ne wo ks, suppo ec o machines, and Bayesian. A decision ee is a hie a chical model o supe ised lea ning. I is an e icien nonpa ame ic me hod ha can be used in classi ica ion o eg ession p oblems. Random Fo es is an ensemble o a decision ee ha combines p edic ions using a se o decision ees o ob ain he mos ele an esul (Alpaydin, 2014). Somani and Deka (2018) explained ha eg ession echniques a e obus in dealing wi h bina y classi ica ion p oblems and gene ally sol e p oblems wi h cause-e ec ela ionships o p edic e en s in a con ex . The au ho s also men ion ha logis ic eg ession is he base o da a analy ics and uses independen a iables o p edic he dependen a iable. A neu al ne wo k is a pa allel dis ibu ed p ocesso made up o simple p ocessing uni s wi h a na u al p opensi y o s o ing expe ien ial knowledge and making i a ailable o use. The knowledge acqui ed by he ne wo k is om i s en i onmen h ough a lea ning p ocess— he neu al ne wo k p oduces consis en ou pu s o inpu s no encoun e ed du ing aining. In addi ion, he in o ma ion p ocessing capabili ies make i possible o i o ind easonable app oxima e solu ions o complex p oblems ha a e in ac able (Haykin, 2009). The pe o mance and accu acy o a p edic i e model can be a ec ed by inconsis encies in he da a s uc u e, such as missing alues and ou lie s. Wi en, F ank, and Hall (2011) a i m ha missing 11 alues indica e blanks in he da ase ; ha may occu o se e al easons and should be ea ed ca e ully. Tan, S einbach, and Kuma (2014) sugges he ollowing s a egies o handle missing alues: elimina e da a o a ibu es, es ima e missing da a, igno e, o co ec disc epancies easily de ec ed du ing he analysis. Kellehe , Namee and D’A cy (2015) a gue ha ou lie s a e alues ha p e ail dis an om he cen al endency. They can be in alid and alid, whe e in alid ou lie s a e alues included in a sample h ough e o ; alid ou lie s a e co ec alues di e en om he es o he ea u e's alues. Ou lie s can be app oached by examining he minimum and maximum alues o each ea u e and using domain knowledge o de e mine; compa e he gaps be ween he median, minimum, maximum, i s qua ile, and hi d qua ile alues. Classi ica ion me ics help e alua e he pe o mance o he models om di e en pe spec i es. Hull (2019) de ines accu acy a io as he pe cen age o obse a ions classi ied co ec ly, as long as p ecision ep esen s he pe cen age o posi i e p edic ions in a classi ica ion model. Con e sely, Molin (2021) deno ed ha e o a e es ima ion alida e he success a e measu ed by accu acy. The au ho sugges s calcula ing he ecall o alida e he accu acy in he scena io o un eliabili y due o an imbalanced class – ecall indica es he ue posi i e a e. In addi ion, Tan, S einbach, and Kuma (2014) assume ha he F-sco e measu e is he ha monic mean be ween ecall and p ecision; and esou ces such as he con usion ma ix p o ides a concise ep esen a ion o classi ica ion pe o mance o classi ie s. Ano he aluable ool o agg ega e e alua ion is he ecei e ope a ing cha ac e is ic cu e (ROC) – i displays he ade-o be ween a ue posi i e a e and a alse-posi i e a e. Table 2.1 p esen s he o mulas o calcula e he me ics. Me ic Fo mula Accu acy E o a e P ecision Recall F sco e Figu e 2.1 - Classi ica ion me ics o mula. 12 Pa ial Dependence Plo s helps unde s and he na u e o he a iables' dependence, p o iding a quali a i e desc ip ion o i s p ope ies. By he unc ion, i is isually possible o iden i y he mos a ec ed ea u e in he model (Has ie, Tibshi ani and F iedman, 2008). Co ez e al. (2009) p oposed esea ch on wine quali y assessmen , applying a eg ession app oach h ough da a mining echniques o e alua e he quali y o he wine based on i s p ope ies and pa e ns. Lee, Pa k and Kang (2015) also in oduced a p edic i e model using a decision ee algo i hm by ecu si e subdi ision o p edic as e p e e ences based on wine's physiochemical cha ac e is ics. Leona di and Po inale (2017) p esen ed a chemical-analy ic amewo k ha aimed o classi y wine p o iles exploi ing chemical ea u es o ace and de e mine au hen ici y assessmen o p o ec be e age agains ake e sions o some o he highes quali y. F ank and Kowalski (1984) de eloped a linea eg ession me hod o unde s and he ela ionship be ween chemical elemen s and senso y e alua ion o a ew wine samples. As a pa o he quali y measu emen s, he esea che s could p edic geog aphic o igin and indi idual senso y pa ame e s o e he quali y o wines. 13 3. METHODOLOGY This chap e desc ibes he me hodology add essed o accomplish he objec i es de ined in he s udy. I includes he esea ch design, da a sou ce speci ica ion, me hods o collec ing and explo ing da a, and u he s eps pe o med in he in es iga ion's wo k low o build he p edic i e model. 3.1. RESEARCH APPROACH AND DESIGN Explo a o y esea ch s i es o ind new insigh s o assess opics in a new pe spec i e and helps o cla i y a si ua ion (Saunde s and Lewis, 2012). This esea ch aims o explo e pa e ns o Po uguese wines collec ed om Vi ino o quali y p edic ion pu poses. The esea ch popula ion encompasses ed and whi e wines. Hapke and Nelson (2020) sugges ha machine lea ning pipeline s a s wi h da a inges ion and ecei es eedback abou how he ained model pe o ms. Al hough, he pipeline building includes a ious s eps ha in ol e cleanliness and da a p ocessing be o e de eloping he model. Despi e he o he exis en app oaches in da a mining, his s udy implemen s he wo k low p esen ed in igu e 3.1 and desc ibed below. Fu he mo e, he da a p ocessing and aining a e sepa a ed o each wine ype analysed in he s udy due o i s cha ac e is ics. Figu e 3.1 - Da a p ocessing wo k low. 3.1.1. Da a ex ac ion and inges ion In his s udy, he p ima y da a sou ce is he online wine ma ke place Vi ino. I implemen s an API ha e u ns a la ge amoun o wine da a. The e o e, a cus omised web c awle in Py hon is necessa y o connec o he applica ion in e ace and ob ain he da a om Vi ino. Da a can be ex ac ed om Vi ino in se e al manne s because i s API e u ns in o ma ion in a JSON o ma . Howe e , o accomplish his in es iga ion's objec i e, a py hon sc ip sc aps he API da a and s o e he e ie ed in o ma ion in he da abase. The collec ed da a is exclusi e o Po uguese wines, including all speci ici ies a ailable on he websi e. Vi ino classi ies Po uguese wines in o he ollowing ypes: ed, whi e, o i ied, ose, spa kling and desse . Hence, he ypes explo ed in his s udy will obey he equi alen classi ica ion. 14 3.1.2. Da a p epa a ion and alida ion Da a is he ounda ion o machine lea ning models, and i s pe o mance depends on he cleansing, use ulness, and alida ion. Consequen ly, da a quali y is undamen al o he esul o his esea ch. The p incipal goal in his phase is o unde s and and o ganise he ga he ed aw da a o be analysed. The ac ions aken in his p ocess include he de ec ion o da a anomalies and ailu es, iden i ying ea u es ha hold missing and inconsis en alues, and emo ing mos o he w ong in o ma ion collec ed be o e beginning he explo a o y analysis on he pipeline. 3.1.3. Da a p ep ocessing and explo a ion This phase in ol es he explo a o y da a analysis using s a is ical me hods and g aphic ep esen a ion o disco e pa e ns, co ela ions, and pai wise a iables o ea u es selec ion. The examina ion in his s age also se es o iden i y ailu es no obse ed du ing he da a p epa a ion, like ea men o missing alues and ou lie s. 3.1.4. Model aining A e unde s anding and p ep ocessing Po uguese wines in he da ase , he in o ma ion equi ed o de elop a p edic i e model is a ailable in he sui able s anda d o make p edic ions abou wine quali y. The da a mining me hods used in his s udy p oceeds wi h Random Fo es , Logis ic Reg ession and Mul i-laye pe cep on classi ie . Subsequen ly, he lea ning algo i hms use he quali y a iable o p edic an ou pu based on wine senso y da a. Random Fo es algo i hm has a nonlinea app oach and is help ul o deal wi h classi ica ion and eg ession p oblems. I uses a collec ion o decision ee algo i hm o disco e impo an ea u es and make he decision. A e de ining he collec ion o ees – namely o es , a o ing mechanism is execu ed o de e mine he p edic ed alue, hen he sum o ees’ p ognos ica ions is used o de e mine he inal p edic ion. The me hod has a simple applica ion and is eac i e o noisy da a and missing alues in he da ase . Logis ic eg ession is a linea algo i hm classi ica ion and has a nume ic ou pu . The e o e, i is scalable o la ge da ase s and is no compu a ionally demanding. The p ima y me hod's p inciple is o es ima e he pos e io p obabili y om he aining da a. Thus, i minimizes he bina y c oss- en opy loss o each da a poin . Figu e 3.2 - De ini ion o Logis ic Reg ession model. 15 The Mul i-laye pe cep on classi ie is an a i icial neu al ne wo k ha can be used o classi ica ion o eg ession objec i es. The me hod can ha e mul iple inpu s and uses a single ou pu wi h a h eshold ac i a ion unc ion. I ains in e ac i ely and p opaga es o wa d, classi ying by selec ing he ou pu s ha p oduce he highes ou pu . Figu e 3.3 - Mul i-laye pe cep on. The machine lea ning lib a y sci-ki -lea n we e employed o build and ain he models. Addi ionally, he algo i hms a e pe o med o ed and whi e wines, applying he same con igu a ion se . 3.1.5. Model analysis and alida ion A his poin , he alida ions o he buil models ake place. Modelling e alua ion is essen ial o assess he alidi y o da a p oduced by he model and compa e he esul s. The ollowing asks un in he phase: ▪ E alua e he e ec i eness o he models, e o s, and limi s. ▪ Execu e c oss- alida ion. ▪ Models' compa ison and analysis o he esul s. ▪ Analyse classi ica ion and eg ession me ics. 22 The wine body leads o he d ink's weigh sensa ion in he mou h. Compa able o alcohol, i is no a ea u e supplied by use s du ing he e alua ion p ocess – i is an in e nal Vi ino's classi ica ion ha anges om 1 o 5. Despi e no being di ec ly associa ed wi h in ensi y and alcohol a ibu es, is no iceable a connec ion in be ween. Whi e wines a e ligh e -bodied, ha e less alcohol olume in con en , and consequen ly lowe in ensi y esolu ion. Figu e 4.5 - Body, alcohol, and in ensi y in ed and whi e wines. I seems he p icing a angemen o wines in Vi ino is based on ex e nal sou ces. Due o he ocus on he ma ke place, he websi e migh e i y local ma ke pa ne s o ob ain he alue o a speci ic o a se o wines. The e is no p ice in o ma ion o e e y wine in he da ase – 22.787 does no ha e a p ice, bu i could gene ally sugges i he wine has low o high quali y. In he case o Po uguese wines in his s udy, he p ice is balanced a 22.26 eu os o ed wine and 11.91 eu os o whi e. Figu e 4.6 - P ice his o y o ed and whi e wines. 23 The a ibu e acidi y s yle did no deno e a signi ican pa e n ha could con ibu e o he model building – i holds a s anda d alue o mos o he eco ds and could cause inconsis encies o he pe o mance. In addi ion, he esul o p ocessing and analysing he da ase p oduced eigh a iables o he u he s eps: acidi y, in ensi y, swee ness, annin, alcohol, wine body, p ice, and quali y. 4.3. DATA PROCESSING AND EXPLORATORY ANALYSIS 4.3.1. Co ela ions and mul i a ia e analysis The Pea son co ela ion coe icien displayed in igu e 4.7 indica es ha in ensi y, alcohol and wine body ha e a nega i e and weak associa ion wi h acidi y, whe e highe acidi y implica es lowe ing in ensi y. Con e sely, acidi y posi i ely co ela es wi h annin, ein o cing he ole o annic cha ac e is ics o balance he acidi y. The e o e, mo e in ensi y p esumes he ed wine has a highe pe cen age o alcohol, is hea yweigh , and be e quali y. Swee ness is also nega i ely co ela ed o acidi y, in ensi y and annin as e. Consequen ly, he highe he acidi y, he less swee wine will be; o he wise, swee ness has a s ong ela ionship wi h alcohol due o i s esidual con en in he e men a ion p ocess and i ele an associa ion wi h quali y and p ice. Despi e he connec ion wi h quali y and alcohol, he p ice has a weak co espondence wi h o he a ibu es. In essence, Vi ino's e alua ion indica es ha he cha ac e isa ion o high-quali y Po uguese ed wine is in insically ela ed o in ensi y esolu ion. I is ull-bodied, has a high pe cen age o alcohol and annic p ope ies o equilib a e acidi y and alcohol olume. Figu e 4.7 - Red wine a ibu es co ela ion. 24 In he case o Po uguese whi e wines, he co ela ions be ween a ibu es di e om ed wine, mainly o i s in ensi y. This cha ac e is ic has a s ong nega i e associa ion wi h acidi y, wine body, alcohol, and swee ness. Mo e acidi y, less is he amoun o hese p ope ies in wine con en . Unde o he condi ions, swee ness has a posi i e co ela ion wi h in ensi y. I demons a es ha i he wine body and in ensi y inc ease in whi e wine, he bigge he pe cep ion o swee ness will be. The e o e, alcohol plays a ele an ole in he whi e wine senso y cha ac e is ics and s ongly ela es o he wine body. The e is no annic p ope y o whi e wines in he da ase ; ne e heless, i seems he swee ness as e cha ac e is ic does he equilib ium among he excess o acidi y and alcohol, e en in modes p opo ion. Figu e 4.8 - Whi e wine a ibu es co ela ion. The numbe o e alua ions o ed wines is mo e subs an ial han whi e wines – i is why he a ing is mo e no able, albei he numbe o whi e wines in he da ase is p opo ionally smalle . In ensi y and alcohol a e pe cep ibly mo e p esen in ed han whi e wines. No wi hs anding, i is likely o ein o ce ha high-quali y ed is ull-bodied while whi e wines a e ligh -bodied, bo h sco ing gene ous alcohol olume in i s con en . The o e all quali y o ed and whi e ypes compa ed o in ensi y and alcohol is exposed in igu e 4.9. 25 Figu e 4.9 - Quali y, in ensi y, and alcohol compa ison. 4.3.2. Missing alues Missing alues can impac he quali y o machine lea ning models and mislead conclusions. Un o una ely, despi e he a ious me hods de eloped o ea he absence o alues, he e is no pe ec app oach o he p oblem. Gi en hese poin s, he da ase in his esea ch has missing alues o all he senso y cha ac e is ics, alcohol, and wine body, as exhibi ed in able 4.4. Wine ype Acidi y In ensi y Swee ness Tannin Alcohol Wine body Red 754 754 754 758 6237 113 Whi e 350 350 350 NA 2173 54 Fo i ied 3368 3368 3368 3838 1035 13 Desse 135 135 135 188 48 85 Table 4.4 - Missing alues. The e a e no missing alues o he a ge a iable - he quali y assignmen is a ailable o all wine ypes. The app oach u ilised o de e mine he missing alues was h ough da a impu a ion. Ins ead o emo ing essen ial columns, he mean and in e pola ion echniques we e employed o ea ange da a. The mean impu a ion was implemen ed o calcula e alues in he alcohol column and in e pola ion o he o he a ibu es. A linea eg ession app oach was applied o imp o e he da a ul ilmen , bu he esul dec eased 0,23% he es ima ed alue o alcohol con en compa ed o mean impu a ion. Due o he endency o high alcohol pe cen age o high-quali y wines, he mean me hod i ed be e , as did he in e pola ion. Fo senso y cha ac e is ics and wine's body we e used linea in e pola ion in o wa ds di ec ion. The me hod es ima es unknown alues based on p e ious a es. No ele an de ia ion was ound a e pe o ming he impu a ion o he missing alues. 26 Figu e 4.10 - Co ela ion ma ix a e handling missing alues. 4.3.3. Ou lie s The a ibu es in bo h da ase s exhibi se e al de ia ions om hei cen al dis ibu ion. The senso y cha ac e is ics a e sligh ly away om he s anda d, which could be jus i ied by how use s slide he ange in he e alua ion p ocess - some de ice's sc eens can be oo sensi i e o he ouch and may add new a iances. In he case o alcohol, mos o he wines con ain misin o ma ion o ed and whi e wines. Unusual dis ibu ions a e also ound on he wine body and in ensi y. Figu e 4.11 - Red wines be o e emo e ou lie s. 27 Figu e 4.12 - Whi e wines be o e emo e ou lie s. Two echniques we e employed o manage ou lie s: in e qua ile ange and Z-sco e. The Z-sco e app oach consumed mo e compu ing esou ces and did no deal well wi h he senso y cha ac e is ics’ de ia ion. Mo eo e , i e ained wines wi h an alcohol le el o o e 15%. On he o he hand, he in e qua ile ange emo ed wines wi h an alcohol pe cen age o e 14.75 o ed and 13.75 o whi es, esul ing in an exclusion o o e 1000 wines. Table 4.5 highligh s he minimum, maximum, mean, and in e qua ile ange ound o each ea u e. Fea u e Min Max Mean IQR Red Whi e Red Whi e Red Whi e Red Whi e Acidi y 1.98 1.62 4.31 4.73 3.09 3.41 3.48 5.93 In ensi y 2.25 1.35 5.0 5.0 4.09 2.75 5.25 3.93 Swee ness 1.0 1.0 3.33 3.55 1.75 1.58 2.55 2.34 Tannin 2.17 NA 4.43 NA 3.25 NA 4.40 NA Alcohol 9.0 8.0 19.50 20.0 13.84 12.61 14.75 13.75 Wine body 1.0 1.0 5.0 5.0 4.31 2.18 6.5 4.5 Quali y 2.0 2.3 4.9 4.70 3.71 3.69 4.75 4.5 Table 4.5 - Ou lie s alues. A e analysing he ou lie s o bo h wines and ponde ing he loss o senso y da a, he bes app oach was o combine manual emo al – as a esul o il e ing and obse a ion – wi h an in e qua ile ange me hod. Table 4.6 p esen s he s a egy applied o alcohol, quali y, in ensi y, wine body, and annin. 28 Fea u e Red wine Whi e wine Alcohol > 16 and < 10 > 15 and < 9 Quali y > 4.7 and < 2.5 > 4.5 and < 2.7 In ensi y IQR < 2.9446820000000007 IQR > 3.932174493750001 Body IQR < 2.5 IQR > 4.5 Tannin IQR > 4.4023140000000005 No applicable Table 4.6 - Handling ou lie s. Images 4.13 and 4.14 display he ea u es a e applying he adop ed s a egy o handle ou lie s. Despi e he wide ange o alues in alcohol, i was no en i ely emo ed due o he accu acy in he label scanning and espec i e alida ion in he ex ac ed wines. Figu e 4.13 - Red wines a e emo e ou lie s. 29 Figu e 4.14 - Whi e wines a e emo e ou lie s. 4.3.4. Final a iables selec ion and a ge de ini ion The p incipal ea u es de ined o p edic he quali y o Po uguese ed and whi e wines a e acidi y, in ensi y, swee ness, annin, wine body and alcohol. Tannic as e p ope y is no applicable o whi e wines. Yea , p ice, and acidi y s yle did no indica e an ou s anding con ibu ion o building he model. Mos o he eco ds had missing alues o p ice; he acidi y s yle also held he same alue o mos o he wines. Quali y has been conside ed he a ge a iable o ain he model. In o de o ame he ca ego ical a ibu e in o a classi ica ion p oblem, i was ans o med o bina y, whe e 1 indica es high quali y and 0 low quali y. 4.4. MODEL BUILDING The model aining s ep consis s in aking inpu s o p edic a desi able ou pu . The a ge sough in he s udy is o p o ide he cus ome 's e alua ion collec ed on Vi ino o Po uguese wines as inpu and ob ain he quali y p edic ion. Modelling da a demands he ea u es' s anda diza ion and hen spli ing he da ase o aining. Da a no maliza ion equalizes he ange o da a in he da ase , ans o ming i in o a mean dis ibu ion o 0 and a de ia ion o 1. In he con ex o supe ised lea ning, a bina y ans o ma ion is equi ed o classi ica ion p oblems; hence, in o de o assume an es ima ion o he quali y, i was de e mined ha a good quali y o ed o whi e wine sco es a alue g ea e han 3.9. This a e ep esen s no e 90 in he expe 's 30 amewo k. Consequen ly, he ea u es de ined o ain he model a e acidi y, in ensi y, swee ness, annin o ed wines, alcohol, and wine body. The app oach adop ed o spli da a is 75% o he aining se and 25% o es ing. Be o e de ining he me hod ha could p edic he bes accu acy o wine quali y, a ew classi ica ion me hods we e es ed, including pa ame ic and non-pa ame ic models. Ne e heless, only he echniques ha pe o med well o espond o he p oposed p oblem will be discussed in he model e alua ion. 4.5. MODEL EVALUATION The esul s demons a e ha he Random Fo es model ob ained he bes accu acy, achie ing 85% o ed and 84% o whi e wines, ollowed by mul i-laye pe cep on and Logis ic eg ession. Table 4.7 exposes he de ailed accu acy ob ained o each model. In ed wines, he aining se con ained 14.238 eco ds o six ea u es, and in aining, 4.747. In he case o whi e wines, 5.597 and 1.866 o he aining and es ing se , espec i ely. Model Red wine Whi e wine T aining Tes ing T aining Tes ing Random Fo es 0.93 0.85 0.93 0.84 Mul i-laye pe cep on 0.84 0.80 0.85 0.83 Logis ic Reg ession 0.74 0.75 0.79 0.78 Table 4.7 - Model's sco ing pe o mance. The Random Fo es model pe o med be e o bo h wine's ypes; howe e , he accu acy was sligh ly highe o ed wines due o he size o se s and be e decision ees esolu ion. A hype pa ame e unning was es ed o enhance he model's accu acy by changing he es ima o s and he limi o ea u es, bu he pe o mance did no signi ican ly inc ease. The s anda d pa ame iza ion had 200 es ima o s o ees in he o es and uses he en opy c i e ium o sea ch o he be e ea u es o spli by. Al oge he , he model sepa a ely egis e ed a a e loss o 0.14 and 0.152 o ed and whi e wines. Figu e 4.15 - Model accu acy sco ing o ed and whi e wines. 31 The Mul i-laye Pe cep on classi ie had i s neu al ne wo k s uc u e se as 100 neu ons in he hidden laye and he ec i ied linea uni as he ac i a ion unc ion. The sol e i e a ed 400 imes o each da a poin un il con e ging he op imiza ion; he weigh op imiza ion ha pe o med be e was he s ochas ic g adien – namely Adam. The cons an lea ning a e was 0.001. E en hough he classi ie p oduced di e en p edic ions when un, he model pe o med be e in he whi e wines scena io, eaching an e o pe cen age a e o 0.19 and 0.16 o ed and whi e wines, espec i ely. Figu e 4.16 - ROC cu e om MLP Classi ie model o ed and whi e wines. Logis ic eg ession was he model ha had he lowes achie emen in he aining and es ing se s. To imp o e he model's pe o mance, he ollowing se ings we e implemen ed: egula iza ion, class weigh , numbe o in e ac ions and andomness s a e. As a esul , he model misclassi ied 24% o he ed wines and 21% o he whi es. Consequen ly, he model pe o med be e o whi e wines – ob aining a p ecision o 62% o p edic high-quali y wines. Table 4.8 enume a es he p edic ed labels o he ac ual labels h ough a con usion ma ix. Red wine Whi e wine P edic ed Bad P edic ed Good P edic ed Bad P edic ed Good Ac ual bad 3.343 [TN] 171 [FP] 1.461 [TN] 6 [FP] Ac ual good 989 [FN] 244 [TP] 389 [FN] 10 [TP] Table 4.8 - Con usion ma ix om logis ic eg ession model. In o de o be e unde s and he esul s o he model's pe o mance, ano he esou ce o he Sciki - lea n lib a y was employed, namely he classi ica ion epo . Tables 4.9 and 4.10 summa ize he achie emen s o low and high-quali y wine. The accu acy lis ed in able 4.7 e e s o he sco e unc ion p o ided by he model esul – he classi ica ion epo calcula es he accu acy as pe he o mula. 38 Jackson, Ronald S. (2020). Wine science p inciples and applica ions (5 h ed.). Else ie . Johnson, Hugh., & Robinson, Jancis. (2013). The Wo ld A las o Wine (7 h ed.). Oc opus Publishing. Kellehe , John D., Namee, B ian Mac., & D’A cy, Aoi e. (2015). Fundamen als o machine lea ning o p edic i e da a analy ics Algo i hms, Wo ked Examples, and Case S udies. The MIT P ess. La ose, Daniel T. (2015). Da a mining and p edic i e analy ics (2nd ed.). Wiley. Lee, Seunghan., Pa k, Juyoung., & Kang, Kyung ae. (2015). Assessing wine quali y using a decision ee. Jou nal o Wine Resea ch, 26(4), 304-318. h ps://doi.o g/10.1109/SysEng.2015.7302752 Leona di, Gio gio., & Po inale, Luigi. (2017). Applying Machine Lea ning o High-Quali y Wine Iden i ica ion. IA 2017 Ad ances in A i icial In elligence, 10640, 31-43. h ps://doi.o g/10.1007/978-3-319-70169-1_3 Lino , Go don S. (2016). Da a Analysis Using SQL and Excel (2nd ed.). Wiley. Malaska, Ted., & Seidman, Jona han. (2018). Founda ions o A chi ec ing Da a Solu ions. O’Reilly. Mayson, Richa d. (2020). The wines o Po ugal. In ini e Ideas. Mi chell, Ryan. (2018). Web Sc aping wi h Py hon Collec ing Mo e Da a om he Mode n Web. O’Reilly. Molin, S e anie. (2021). Hands-On Da a Analysis wi h Pandas: A Py hon da a science handbook o da a collec ion, w angling, analysis, and isualiza ion (2nd ed.). Pack Publishing. Palade, Mihai., & Popa, Mona-Elena (2014). Wine aceabili y and au hen ici y – a li e a u e e iew. Scien i ic Bulle in. Se ies F. Bio echnologies, XVIII, 2285-1364. h ps://www. esea chga e.ne /publica ion/268817852_WINE_TRACEABILITY_AND_AUTHENTI CITY_-_A_LITERATURE_REVIEW Psal is, And ew. (2017). S eaming Da a unde s anding he eal- ime pipeline. Manning Publica ions. Quin ela, H., Ca nei o, D., & Fe ei a, L. (2020). Business In elligence, Big Da a and Da a Go e nance. In Melo, Ped o N., & Machado, Ca olina (Eds.), Business In elligence and Analy ics in Small and Medium En e p ises (pp. 123-147). CRC P ess. Saunde s, M., & Lewis, P. (2012). Doing Resea ch in Business and Managemen : An Essen ial Guide o Planning You P ojec . Pea son Educa ion. Somani, A un K., & Deka, Ganesh Chand a. (2018). Big Da a Analy ics Tools and Technology o E ec i e Planning. CRC P ess. Tan, Pang-Ning., S einbach, Michael., & Kuma , Vipin. (2014). In oduc ion o Da a Mining. Pea son Educa ion. Ta e sall, Ian., & Desalle, Rob. (2015). A Na u al his o y o wine. Yale Uni e si y P ess. 39 Wi en, Ian H., F ank, Eibe., & Hall, Ma k A. (2011). Da a mining p ac ical machine lea ning ools and echniques (3 d ed.). Else ie . Page | i