Sens Map
Sens Map
URL https://github.com/IbtihelRebhi/SensMap
Description Provides Sensory and Consumer Data
mapping and analysis <doi:10.14569/IJACSA.2017.081266>. The mapping visualiza-
tion is made available
from several features : options in dimension reduction methods and prediction models rang-
ing from
linear to non linear regressions. A smoothed version of the map performed using lo-
cally weighted regression algorithm
is available. A selection process of map stability 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 also made available.
Depends R (>= 4.0), stats, grDevices, graphics
Imports doBy, lattice, FactoMineR, MCMCpack, factoextra, fields,
ggdendro, glmulti, mgcv, plotly, shiny, ggplot2, reshape2
License GPL (>= 2)
LazyData TRUE
Suggests testthat
RoxygenNote 7.1.2.9000
Encoding UTF-8
NeedsCompilation no
Repository CRAN
Date/Publication 2022-07-04 19:00:02 UTC
1
2 hedo_biscuit
R topics documented:
hedo_biscuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
PrefMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
SensMapUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
sens_biscuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
SmoothMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
StabMap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Index 11
Description
hedo_biscuit data was collected from ratings of 294 consumers towards 8 products (cookies).
Usage
hedo_biscuit
Format
Value
Source
References
Pages et al. Sensory analysis comparison of eight biscuits by French and Pakistani panels, 2007,
Journal of Sensory Studies 22(6), 665-686.7
PrefMap 3
Description
function that provides external preference mapping technique and visualizes consumers preferences
in the prediction space provided by the principal components obtained from application of dimen-
sion 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.
Usage
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)
Arguments
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 lm : Quadratic model, the cor-
responding formula = "~I(F1*F1)+I(F2*F2)+F1*F2". Vector model, the for-
mula = "~ F1 + F2". Circular model, the formula="~ F1 + F2 + (F1*F1 +
F2*F2)". Elliptic model, the formula = "~I(F1*F1)+I(F2*F2)". If predmodel=
2, Generalized Additive models (GAM) structure performed using gam, pro-
posed formula="~s(F1,k=3)+s(F2,k=3)". If predmodel= 3, Generalized Linear
Models(GLM) structure performed using glm, proposed formula = "~I(F1*F1)+
I(F2*F2)+ F1*F2". If predmodel= 4, Bayes structure performed using MCMCregress,
proposed formula="~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).
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.
4 PrefMap
pred.na boolean, if TRUE, predictions outside the set of liking scores are removed (gen-
erally [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.
Details
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 in-
fluence positively or negatively their liking (Danzart,2004). Classically, A Principal Component
Analysis is performed (PCA) on the descriptive data. Individual consumer responses are then re-
gressed 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.
Value
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.
Author(s)
Ibtihel Rebhi, Dhafer Malouche
References
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 tech-
niques: finding out a consumer optimal product, its sensory profile and the key sensory attributes.
7th Sensometrics Conference, July 27-30, 2004, Davis, CA
See Also
SmoothMap, StabMap, SensMapUI
SensMapUI 5
Examples
# 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
Description
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 like-
wise 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.
Usage
SensMapUI()
Value
No return value, called for launching application
6 sens_biscuit
Author(s)
Ibtihel Rebhi, Dhafer Malouche
See Also
PrefMap, SmoothMap, StabMap
Examples
## Not run:
library(SensMap)
SensMapUI()
## End(Not run)
Description
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.
Usage
sens_biscuit
Format
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
Value
No return value, called for data loading
Source
Francois Husson data sets
References
Pages et al. Sensory analysis comparison of eight biscuits by French and Pakistani panels, 2007,
Journal of Sensory Studies 22(6), 665-686.7
SmoothMap 7
Description
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.
Usage
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)
Arguments
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 Canon-
ical 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 lm : Quadratic model, the cor-
responding formula = "~I(F1*F1)+I(F2*F2)+F1*F2". Vector model, the for-
mula = "~ F1 + F2". Circular model, the formula="~ F1 + F2 + (F1*F1 +
F2*F2)". Elliptic model, the formula = "~I(F1*F1)+I(F2*F2)". If predmodel=
2, Generalized Additive models (GAM) structure performed using gam, pro-
posed formula="~s(F1,k=3)+s(F2,k=3)". If predmodel= 3, Generalized Linear
Models(GLM) structure performed using glm, proposed formula = "~I(F1*F1)+
I(F2*F2)+ F1*F2". If predmodel= 4, Bayes structure performed using MCMCregress,
proposed formula="~I(F1*F1)+I(F2*F2)+F1*F2".
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 (gen-
erally [0:10]), if FALSE, we keep all predictions in and outside the set of liking
scores.
8 SmoothMap
Value
z.loess object of class loess obtained from fitting a polynomial surface determined by the compo-
nents 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 compo-
nents 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
Author(s)
Ibtihel Rebhi, Dhafer Malouche
See Also
PrefMap, StabMap, SensMapUI
Examples
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
StabMap 9
Description
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 pref-
erences (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.
Usage
StabMap(Y,X,S,n,axis=c(1,2),formula_lm,
formula_gam,formula_glm, dimredumethod=1,
pred.na=FALSE,nbpoints=50)
Arguments
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 Canon-
ical 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.
Value
sum squared distances of preferences computed between maps before and after LOESS smoothing
for each prediction model.
10 StabMap
Author(s)
Ibtihel Rebhi, Dhafer Malouche
See Also
PrefMap, SmoothMap,SensMapUI
Examples
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)
#library(reshape2)
#res_stab=melt(res_stab)
#colnames(res_stab)=c("prob", "var", "value")
# Visualization of stability results
#library(ggplot2)
#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
Index
∗ hedo_biscuit
hedo_biscuit, 2
∗ sens_biscuit
sens_biscuit, 6
gam, 3, 7
glm, 3, 7
hedo_biscuit, 2
lm, 3, 7
MCMCregress, 3, 7
PrefMap, 3, 6, 8, 10
sens_biscuit, 6
SensMapUI, 4, 5, 8, 10
SmoothMap, 4, 6, 7, 10
StabMap, 4, 6, 8, 9
11