Title: | Sensory and Consumer Data Mapping |
---|---|
Description: | External preference mapping technique is commonly used in sensory analysis field to explain consumer preferences in function of sensory attributes of products Danzart(1998) (<doi:10.1006/fstl.1998.0373>). The package provides map visualization with options in dimension reduction methods and prediction models from linear and non linear regressions. A smoothed version of the map performed using LOESS algorithm is available. A comparison approach of maps stability from different features before and after smoothing is provided. A 'shiny' application is included. It presents an easy GUI for the implemented functions as well as a comparative tool of fit models using several criteria. Basic analysis such as characterization of products, panelists and sessions likewise consumer segmentation are available. |
Authors: | Ibtihel Rebhi [aut, cre], Rihab Boubakri [ctb], Dhafer Malouche [ctb] |
Maintainer: | Ibtihel Rebhi <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.3 |
Built: | 2024-10-26 03:57:10 UTC |
Source: | https://github.com/ibtihelrebhi/sensmap |
hedo_biscuit data was collected from ratings of 294 consumers towards 8 products (cookies).
hedo_biscuit
hedo_biscuit
produit
factor : numbering the 8 products
consumers
294 consumers : ratings of consumers
Francois Husson data sets
Pages et al. Sensory analysis comparison of eight biscuits by French and Pakistani panels, 2007, Journal of Sensory Studies 22(6), 665-686.7
function that provides external preference mapping technique and visualizes consumers preferences in the prediction space provided by the principal components obtained from application of dimension reduction method (PCA, MFA and CA) to quantitative
descriptive variables. The prediction can be fitted either from Polynomial regressions lm
, GAM gam
, GLM glm
or Bayesian models MCMCregress
. The surfaces of predictions and preferences are displayed in 2D and 3D.
PrefMap(Y,X,S,axis=c(1,2),formula,dimredumethod=1, predmodel=1,nbpoints=50,pred.na =FALSE, graph.pred =FALSE,graph.map =TRUE, graph.map.3D =FALSE)
PrefMap(Y,X,S,axis=c(1,2),formula,dimredumethod=1, predmodel=1,nbpoints=50,pred.na =FALSE, graph.pred =FALSE,graph.map =TRUE, graph.map.3D =FALSE)
Y |
a data frame in which each row represents a product and each column represents hedonic scores of a given consumer for the products. |
X |
a data frame in which each row represents a product and each column represents evaluations of a given sensory or physico-chemical attribute for the products. |
S |
a data frame crossing products and panelists evaluations of a given sensory or physico-chemical attribute for each product. It's required when choosing Canonical Analysis as dimension reduction method. |
axis |
a length 2 vector specifying the components of dimension reduction method to plot. |
formula |
a formula expression to be introduced. If predmodel=1, it corresponds to four polynomial regression models performed using
|
dimredumethod |
1 is assigned to Principal Component Analysis (PCA). If 2, Multiple Factor Analysis (MFA). If 3, Canonical Analysis (CA). |
predmodel |
the type of prediction model : If predmodel = 1 : Polynomial regression models. If predmodel = 2 : Generalized Additive models (GAM). If predmodel = 3 : Generalized Linear Models (GLM). If predmodel = 4 : Bayesian models. |
nbpoints |
an integer. The number of points in th grid-point of the discretized plan of the map provided by the two first components. By default 50. |
pred.na |
boolean, if TRUE, predictions outside the set of liking scores are removed (generally [0:10]), if FALSE, we keep all predictions in and outside the set of liking scores. |
graph.pred |
boolean, if TRUE, plot of surface prediction of all consumers is posted. |
graph.map |
boolean, if TRUE, extrenal preference mapping in 2 dimensions is posted. |
graph.map.3D |
boolean, if TRUE, extrenal preference mapping is 3 dimensions is posted. |
The external preference mapping method is a very common way used in sensory analysis field to explain hedonic judgments towards products in function of analytic attributes of these products in order to understand the consumers' sensory profile and more especially which characteristics influence positively or negatively their liking (Danzart,2004). Classically, A Principal Component Analysis is performed (PCA) on the descriptive data. Individual consumer responses are then regressed according to the chosen two principal components of PCA. Cards of prediction response surface for each consumer are displayed and then superposed. At each point of the grid, if the predicted value is higher than the mean value of liking score in the hedonic data it is considered as preference point. The map of preferences for all consumers is then obtained. Areas of rejection and preferences are underlined via showing the percentage of consumers.
graph.pred plot of surface predictions
graph.map plot of external preference mapping
graph.map.3D plot of external preference mapping in 3D
nb.NA if pred.na = TRUE, it returns a list of the number of predictions outside the liking scores space for each consumer prediction surface.
pos.NA if pred.na=TRUE, it returns a list of positions of predictions outside the liking scores space for each consumer prediction surface.
occur.NA if pred.na=TRUE, it returns a data frame with total number of predictions outside the liking scores space at each point of the prediction surface of all consumers.
Ibtihel Rebhi, Rihab Boubakri, Dhafer Malouche
Sebastien Le, Francois Husson (2008).SensoMineR: A package for sensory data analysis, Journal of Sensory Studies Volume 23, Issue 1, Pages 14-25
Danzart M., Sieffermann J.M., Delarue J. (2004). New developments in preference mapping techniques: finding out a consumer optimal product, its sensory profile and the key sensory attributes. 7th Sensometrics Conference, July 27-30, 2004, Davis, CA
# Example of external preference mapping performed from PCA and quadratic # regression model. data(hedo_biscuit) data(sens_biscuit) # Make data compatible to the form of X, Y and S rownames(hedo_biscuit)=hedo_biscuit[,1] Y=hedo_biscuit[,-1] library(doBy) juge_senso_bisc<- summaryBy(. ~ produit + juge, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) S=juge_senso_bisc[,-3] prod_bisc=summaryBy(. ~ produit, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) rownames(prod_bisc)= prod_bisc[,1] X= prod_bisc[,-c(1:3)] # Map drawing in 2D map_QR= PrefMap(Y,X,S,axis=c(1,2), formula="~I(F1*F1)+I(F2*F2)+F1*F2", dimredumethod=1, predmodel=1, nbpoints=50,pred.na =FALSE, graph.pred =FALSE, graph.map =TRUE, graph.map.3D =FALSE ) # if pred.na= TRUE total number of NA in each point of the grid-map nb.QR=map_QR$occur.NA # if pred.na=TRUE List of positions of predictions outside [0:10] pos.QR=map_QR$pos.NA # if pred.na=TRUE total number of predictions outside the liking scores space occur.QR=map_QR$occur.NA
# Example of external preference mapping performed from PCA and quadratic # regression model. data(hedo_biscuit) data(sens_biscuit) # Make data compatible to the form of X, Y and S rownames(hedo_biscuit)=hedo_biscuit[,1] Y=hedo_biscuit[,-1] library(doBy) juge_senso_bisc<- summaryBy(. ~ produit + juge, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) S=juge_senso_bisc[,-3] prod_bisc=summaryBy(. ~ produit, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) rownames(prod_bisc)= prod_bisc[,1] X= prod_bisc[,-c(1:3)] # Map drawing in 2D map_QR= PrefMap(Y,X,S,axis=c(1,2), formula="~I(F1*F1)+I(F2*F2)+F1*F2", dimredumethod=1, predmodel=1, nbpoints=50,pred.na =FALSE, graph.pred =FALSE, graph.map =TRUE, graph.map.3D =FALSE ) # if pred.na= TRUE total number of NA in each point of the grid-map nb.QR=map_QR$occur.NA # if pred.na=TRUE List of positions of predictions outside [0:10] pos.QR=map_QR$pos.NA # if pred.na=TRUE total number of predictions outside the liking scores space occur.QR=map_QR$occur.NA
A sensory evaluation was organized in Pakistan to characterize 8 cookies products with a set of 23 quantitative sensory attributes by 12 trained panelists at 2 tasting sessions.
sens_biscuit
sens_biscuit
seance
factor : the tasting sessions 1 and 2
juge
factor : numbering the 12 assessors
produit
factor : numbering the 8 products
23 attributes
quantitative variables : characteristics of products
Francois Husson data sets
Pages et al. Sensory analysis comparison of eight biscuits by French and Pakistani panels, 2007, Journal of Sensory Studies 22(6), 665-686.7
launches a 'shiny' application that provides a Graphical User Interface (GUI) for the functions included in the SensMap package as well as a comparative tool of fit models performance using several criteria. Basic analysis such as characterization of products, panelists and sessions likewise consumers segmentation are also available. The application includes data import in different formats, plot displays and results in tables as well as downloading them. This application is very helpful for practitioners and researchers in sensory analysis field.
SensMapUI()
SensMapUI()
Ibtihel Rebhi, Rihab Boubakri, Dhafer Malouche
## Not run: library(SensMap) SensMapUI() ## End(Not run)
## Not run: library(SensMap) SensMapUI() ## End(Not run)
a function that provides a smoothed version of external preference mapping by performing a locally weighted regression smoothing (LOESS) on the curves of preference level.
SmoothMap(Y,X,S,axis=c(1,2), formula,dimredumethod=1, predmodel=1,pred.na =FALSE,span=.5, degree=2, graphpred=FALSE, drawmap=TRUE, dmap.loess=FALSE, nbpoints=50)
SmoothMap(Y,X,S,axis=c(1,2), formula,dimredumethod=1, predmodel=1,pred.na =FALSE,span=.5, degree=2, graphpred=FALSE, drawmap=TRUE, dmap.loess=FALSE, nbpoints=50)
Y |
a data frame in which each row represents a product and each column represents hedonic scores of a given consumer for the products. |
X |
a data frame in which each row represents a product and each column represents evaluations of a given sensory or physico-chemical attribute for the products. |
S |
a data frame crossing products and panelists evaluations of a given sensory or physico-chemical attribute for the product. It's required when choosing Canonical Analysis as dimension reduction method. |
axis |
a length 2 vector specifying the components of dimension reduction method to plot. |
formula |
a formula expression to be introduced. If predmodel=1, it corresponds to four polynomial regression models performed using
|
dimredumethod |
1 is assignedd to Principal Component Analysis(PCA). If 2, Multiple Factor Analysis(MFA). If 3, Canonical Analysis(CA). |
predmodel |
the type of prediction model : If predmodel = 1 : Polynomial regression models. If predmodel = 2 : Generalized Additive models (GAM). If predmodel = 3 : Generalized Linear Models (GLM). If predmodel = 4 : Bayesian models. |
pred.na |
boolean, if TRUE, predictions outside the set of liking scores are removed (generally [0:10]), if FALSE, we keep all predictions in and outside the set of liking scores. |
span |
the parameter which controls the degree of smoothing by LOESS. |
degree |
the degree of the polynomials to be used, normally between 1 and 2. |
graphpred |
boolean, if TRUE, plot of smoothed surface prediction of all consumers is posted. |
drawmap |
boolean, if TRUE, smoothed version of extrenal preference mapping in 2 dimensions is posted. |
dmap.loess |
boolean, if TRUE, smoothed version of extrenal preference mapping is 3 dimensions is posted. |
nbpoints |
an integer. The number of points in th grid-point of the discretized plan of the map provided with the two first components. By default 50. |
z.loess object of class loess obtained from fitting a polynomial surface determined by the components of dimension reduction method as predictors and consumers predictions as explained variable.
m.loess object of class loess obtained from fitting a polynomial surface determined by the components of dimension reduction method as predictors and consumers preferences as explained variable.
plots of the smoothed prediction surface, smoothed external preference mapping in 2D and in 3D
Ibtihel Rebhi, Rihab Boubakri, Dhafer Malouche
data(hedo_biscuit) data(sens_biscuit) # Make data compatible to the form of X, Y and S rownames(hedo_biscuit)=hedo_biscuit[,1] Y=hedo_biscuit[,-1] library(doBy) juge_senso_bisc<- summaryBy(. ~ produit + juge, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) S=juge_senso_bisc[,-3] prod_bisc=summaryBy(. ~ produit, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) rownames(prod_bisc)= prod_bisc[,1] X= prod_bisc[,-c(1:3)] # Example of smoothed version of external preference mapping for quadratic # model. Smap= SmoothMap(Y,X,S, axis=c(1,2), formula="~I(F1*F1)+I(F2*F2)+F1*F2", dimredumethod=1,predmodel=1,span=.5,degree=2, graphpred=FALSE, drawmap=TRUE, dmap.loess=FALSE) # results of predictions by LOESS smoothing Smap$z.loess Smap$m.loess
data(hedo_biscuit) data(sens_biscuit) # Make data compatible to the form of X, Y and S rownames(hedo_biscuit)=hedo_biscuit[,1] Y=hedo_biscuit[,-1] library(doBy) juge_senso_bisc<- summaryBy(. ~ produit + juge, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) S=juge_senso_bisc[,-3] prod_bisc=summaryBy(. ~ produit, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) rownames(prod_bisc)= prod_bisc[,1] X= prod_bisc[,-c(1:3)] # Example of smoothed version of external preference mapping for quadratic # model. Smap= SmoothMap(Y,X,S, axis=c(1,2), formula="~I(F1*F1)+I(F2*F2)+F1*F2", dimredumethod=1,predmodel=1,span=.5,degree=2, graphpred=FALSE, drawmap=TRUE, dmap.loess=FALSE) # results of predictions by LOESS smoothing Smap$z.loess Smap$m.loess
A function that introduces a comparison approach of maps stability from different strategies before and after LOESS smoothing. It is based on the calculation of an average squared distance of preferences (ASDP) between maps obtained from subsamples of hedonic data through a resampling approach. The strategy with an overall ASDP lower than the other is preferred.
StabMap(Y,X,S,n,axis=c(1,2),formula_lm, formula_gam,formula_glm, dimredumethod=1, pred.na=FALSE,nbpoints=50)
StabMap(Y,X,S,n,axis=c(1,2),formula_lm, formula_gam,formula_glm, dimredumethod=1, pred.na=FALSE,nbpoints=50)
Y |
a data frame in which each row represents a product and each column represents hedonic scores of a given consumer for the products. |
X |
a data frame in which each row represents a product and each column represents evaluations of a given sensory or physico-chemical attribute for the products. |
S |
a data frame crossing products and panelists evaluations of a given sensory or physico-chemical attribute for the products. It's required when choosing Canonical Analysis ad dimension reduction method. |
n |
number of selection of random samples from hedonic data for which maps are compared before and after LOESS smoothing. |
axis |
a length 2 vector specifying the components of dimension reduction method to plot. |
formula_lm |
a formula expression for polynomial regression model for example formula_lm = "~I(F1*F1)+I(F2*F2)+F1*F2". |
formula_gam |
a formula expression for GAM model fitting for example formula_gam = "~s(F1,k=3)+s(F2,k=3)". |
formula_glm |
a formula expression for GLM model fitting for example formula_glm = "~I(F1*F1)+I(F2*F2)+F1*F2". |
dimredumethod |
1 is assigned to Principal Component Analysis(PCA). If 2, Multiple Factor Analysis(MFA). If 3, Canonical Analysis(CA). |
pred.na |
boolean, if TRUE, predictions outside the set of liking scores are removed, if FALSE, all predections are kept in and out the set of liking scores. |
nbpoints |
an integer. The number of points in the grid-point of the discretized plan. By default = 50. |
sum squared distances of preferences computed between maps before and after LOESS smoothing for each prediction model.
Ibtihel Rebhi, Rihab Boubakri, Dhafer Malouche
## Not run: data(hedo_biscuit) data(sens_biscuit) # Make data compatible to the form of X, Y and S rownames(hedo_biscuit)=hedo_biscuit[,1] Y=hedo_biscuit[,-1] library(doBy) juge_senso_bisc<- summaryBy(. ~ produit + juge, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) S=juge_senso_bisc[,-3] prod_bisc=summaryBy(. ~ produit, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) rownames(prod_bisc)= prod_bisc[,1] X= prod_bisc[,-c(1:3)] # Results of comparing maps stability res_stab= StabMap(Y,X,S,n=2,axis=c(1,2), formula_lm="~I(F1*F1)+I(F2*F2)+F1*F2", formula_gam="~s(F1,k=3)+s(F2,k=3)", formula_glm="~I(F1*F1)+I(F2*F2)+F1*F2", dimredumethod=1, nbpoints=50) res_stab=melt(res_stab) colnames(res_stab)=c("prob", "var", "value") # Visualization of stability results gr<-ggplot(res_stab,aes(x=prob,y=value,fill=prob))+geom_boxplot()+xlab("Methods")+ ylab("Average Squared Distance of Preferences") gr<-gr+theme_bw()+theme(legend.position = "none", axis.text.x = element_text(angle = 90)) gr ## End(Not run)
## Not run: data(hedo_biscuit) data(sens_biscuit) # Make data compatible to the form of X, Y and S rownames(hedo_biscuit)=hedo_biscuit[,1] Y=hedo_biscuit[,-1] library(doBy) juge_senso_bisc<- summaryBy(. ~ produit + juge, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) S=juge_senso_bisc[,-3] prod_bisc=summaryBy(. ~ produit, data=sens_biscuit, FUN=c(mean),keep.names = TRUE,na.rm=TRUE) rownames(prod_bisc)= prod_bisc[,1] X= prod_bisc[,-c(1:3)] # Results of comparing maps stability res_stab= StabMap(Y,X,S,n=2,axis=c(1,2), formula_lm="~I(F1*F1)+I(F2*F2)+F1*F2", formula_gam="~s(F1,k=3)+s(F2,k=3)", formula_glm="~I(F1*F1)+I(F2*F2)+F1*F2", dimredumethod=1, nbpoints=50) res_stab=melt(res_stab) colnames(res_stab)=c("prob", "var", "value") # Visualization of stability results gr<-ggplot(res_stab,aes(x=prob,y=value,fill=prob))+geom_boxplot()+xlab("Methods")+ ylab("Average Squared Distance of Preferences") gr<-gr+theme_bw()+theme(legend.position = "none", axis.text.x = element_text(angle = 90)) gr ## End(Not run)