In this paper, Viterbi algorithm based on a hidden Markov model is applied to recognize activity sequences from observed sensors events. Alternative features selections of time feature values of sensors events and activity length size feature values are tested, respectively, and then the results of activity sequences recognition performances of Viterbi algorithm are evaluated. The results show that the selection of larger time feature values of sensor events and/or smaller activity length size feature values will generate relatively better results on the activity sequences recognition performances.
A method to remove chattering alarms using median filters
Influence of time and length size feature selections for human activity sequences recognition
1. ResearchArticle
Influence oftimeandlengthsizefeatureselectionsforhumanactivity
sequencesrecognition
Hongqing Fang a,n, LongChen a, RaghavendiranSrinivasan b
a College ofEnergy&ElectricalEngineering,HohaiUniversity,Jiangsu211100,PRChina
b School ofElectricalEngineering&ComputerScience,WashingtonStateUniversity,WA99163,USA
a rticleinfo
Article history:
Received6January2013
Receivedinrevisedform
17August2013
Accepted4September2013
Availableonline25September2013
Keywords:
Activityrecognition
Featureselections
Hidden Markovmodel
Viterbi algorithm
Smart home
a b s t r a c t
In thispaper,ViterbialgorithmbasedonahiddenMarkovmodelisappliedtorecognizeactivity
sequencesfromobservedsensorsevents.Alternativefeaturesselectionsoftimefeaturevaluesofsensors
events andactivitylengthsizefeaturevaluesaretested,respectively,andthentheresultsofactivity
sequencesrecognitionperformancesofViterbialgorithmareevaluated.Theresultsshowthatthe
selection oflargertimefeaturevaluesofsensoreventsand/orsmalleractivitylengthsizefeaturevalues
will generaterelativelybetterresultsontheactivitysequencesrecognitionperformances.
& 2013ISA.PublishedbyElsevierLtd.Allrightsreserved.
1. Introduction
The smarthomes [1–16] providecontinuousmonitoringcap-
ability thatconventionalmethodologieslack.Beingabletoauto-
mate theactivityrecognitionfromhumanmotionpatternsusing
unobtrusivesensorsorotherdevicescanbeusefulinmonitoring
older adultsintheirhomesandkeepingtrackoftheiractivitiesof
daily livings(ADLs)andbehavioralchanges [13–23]. TheCenterfor
AdvancedStudiesinAdaptiveSystems(CASAS)smarthome
project isamulti-disciplinaryresearchprojectatWashington
StateUniversity,focusedonthecreationofanintelligent
home environment.Theapproachistoviewthesmarthomeas
an intelligentagentthatperceivesitsenvironmentthroughthe
use ofsensors,andcanactupontheenvironmentthroughtheuse
of actuators.TheresearchgoalsoftheCASASsmarthomeproject
aretoenhanceandimprovequalityoflife,prolongstayat
home withtechnology-enabledassistance,minimizethecostof
maintaining thehomeandmaximizethecomfortofitsinhabitants
[8–10].
ToimplementthegoaloftheCASASsmarthomeproject,a
primarychallengeistodesignanalgorithmthatlabelstheactivity
performedbyaninhabitantinasmartenvironmentfromthesensor
datacollectedbytheenvironment duringtheactivity.Medical
professionalsalsobelievethatoneofthebestwaystodetect
emerging medicalconditionsbeforetheybecomeseriousistolook
forchangesintheADLs.Recently,humanactivitydiscoveryand
recognitionhasgainedalotofinterestduetoitsenormouspotential
incontextawarecomputingsystems,includingsmarthomeenvir-
onments.Torecognizeresidents'activitiesandtheirdailyroutines
cangreatlyhelpinprovidingautomation,security,andmore
importanceinremotehealthmonitoringofelderorpeoplewith
disabilities.Themainobjectiveofhumanactivityrecognitionin
smarthomeenvironmentsisto findinterestingpatternsofbehavior
fromsensordataandtorecognizesuchpatterns.Researchershave
commonlytestedthemachinelearningalgorithmssuchas
knowledge-drivenapproach(KDA) [13], evolutionaryensembles
model (EEM) [14], supportvectormachine(SVM) [15], Dempster–
Shafer theoryofevidence(D–S) [16], naïveBayes(NB)classifier,
Markovmodel(MM),hiddenMarkovmodel(HMM)andconditional
random fields(CRF) [17–30], etc.,forhumanactivity(pattern)
recognitioninsmarthomeenvironments.Eventhoughthedatasets
include alargenumberofsensorevents sequencesgeneratedbya
variousactivities,theresultsappearinthesepapersaremainlythe
evaluationandcomparisonofthetotalactivityrecognitionaccuracy
rategeneratedbydifferentmachinelearningalgorithms.Another
shortcomingisthatanyactivityannotatedindatasethasvarious
features.Usually,thesefeaturesvaluesareselectedinonemethodin
all tests.However,theinfluencesofthesefeaturevaluestohuman
activityrecognitionperformance areseldomaddressedinprevious
works.Moreover,itisalsonecessarytorecognizewhichactivities
generatesensoreventssequences.
Contents listsavailableat ScienceDirect
journalhomepage: www.elsevier.com/locate/isatrans
ISATransactions
0019-0578/$-seefrontmatter & 2013ISA.PublishedbyElsevierLtd.Allrightsreserved.
http://dx.doi.org/10.1016/j.isatra.2013.09.001
n Corresponding author.Tel.: þ86 18061705168.
E-mail addresses: fanghongqing@sohu.com, fanghongqing@gmail.com
(H. Fang).
ISA Transactions53(2014)134–140
2. In thispaper,Viterbialgorithmisadynamicprogramming
algorithm for finding themostlikelysequenceofhiddenstates
that resultsinasequenceofobservedevents,especiallyinthe
contextofMarkovinformationsources [31,32] and hiddenMarkov
models [24,25,28–30,33]. Therefore,Viterbialgorithmisappliedto
recognize activitiessequencesfromobservedsensorsevents
sequences.Andthen,alternativefeaturesselectionsaretested
[34–36], and finally theresultsofactivitiessequencesrecognition
performance measuresofViterbialgorithmwithdifferenttime
feature valuesofsensoreventsandactivitylengthsizefeature
valuesareevaluated.
The restofthepaperisorganizedasfollows. Section 2 briefly
describes thesmartapartmenttestbedinstalledintheWashington
StateUniversitycampusandalsothedatacollectionprocedures.
Section 3 describes Viterbialgorithmappliedtorepresentand
recognize humanactivitiessequences. Section 4 presentsthe
results oftheinfluence oftimeandactivitylengthsizefeature
valuestoactivitiessequencesrecognitionsperformances. Section 5
summarizes themaincontributions.
2. Smartapartmenttestbedanddatacollection
ThesmartapartmenttestbedislocatedonWashingtonState
UniversitycampusandismaintainedaspartoftheongoingCASAS
smart homeproject [8–10,18,24–30]. Asshownin Fig. 1, thesmart
apartment testbedincludesthreebedrooms,onebathroom,a
kitchen,andaliving/diningroom.Thesmartapartmentisequipped
with motionsensorsdistributedapproximately1mapartthrough-
out thespaceontheceilings.Inaddition,othersensorsinstalled
provideambienttemperaturereadingsandcustom-builtanalog
sensorsprovidereadingsforhotwater,coldwater,andstoveburner
use. VoiceoverIPusingAsterisksoftwarecapturesphoneusageand
contactswitchsensorstomonitorusageofkeyitemsincluding
a cookingpot,amedicinecontainer,andthephonebook.Lastly,
Insteonpowercontrolsandswitchesareusedtomonitorandcontrol
the lightinginthespace.Sensorsdataarecapturedusingasensor
networkthatwasdesignedin-houseandstoredinaSQLdatabase.
The middlewareusesaXMPP-basedpublish-subscribeprotocolasa
lightweightplatformandlanguage-independentmethodtopush
datatoclienttoolswithminimaloverheadandmaximal flexibility.
Aftercollectingdatafromthesmart apartmenttestbed,thesensors
eventsareannotatedforADLs.Alargenumberofsensorseventsare
generatedeveryday.
The datagatheredbyCASASsmarthomeisrepresentedbythe
following parameters,whichspecifythenumberoffeaturesthat
areusedtodescribethesensorsevents.Thedefaultnumberof
features is5.Thedefaultinterpretationofthe five featuresis:
(1) SensorID,whichisanintegervalueintherangeof0tothe
number oflogicalsensorvalues.
(2) Timeofday,whichistheinputtimeofthesensoreventbutis
discretized toanintegervalue.Thedefaultvalueis5,which
means thetimerangesofoneentiredayare0–5, 6–10,11–15,
16–20, and21–24. Thevalueofthisfeatureisadjustable.
(3) Dayofweek,whichtheinputdateofthesensoreventis
convertedintoavalueintherangeof0–6 thatrepresentsthe
day oftheweekonwhichthesensoreventoccurred.
(4) Previousactivity,whichisanintegervaluethatrepresentsthe
activity thatoccurredbeforethecurrentactivity.
(5) Activitylength,whichrepresentsthelengthofthecurrent
activity measuredinnumberofsensorsevents.Thevalueof
this featureistocalculatethevalueoflengthsizethreshold,
and thedefaultvalueis3,whichmeansthelengthsizeofeach
activity isdistinguishedby3thresholds:{small,medium,
large}. Thevalueofthisfeatureisadjustable.
The generalizedsyntaxofthedatasetisgivenbelow.
Date TimeSensorIDSensorValue 〈label〉
An exampleofthedatasetofNight_wanderingactivityis
{
2009-06-1003:20:59.08M006ONNight_wanderingbegin
2009-06-1003:25:19.05M012ON
2009-06-1003:25:19.08M011ON
2009-06-1003:25:24.05M011OFF
2009-06-1003:25:24.07M012OFFNight_wanderingend
}
This exampleshowsonesensorssequencecorrespondstothe
Night_wanderingactivitywithconcreteDate,Time,SensorID,
SensorValue aswellasactivitylabelparameters [18–30].
3. Viterbialgorithmappliedforactivitysequencesrecognition
An HMMisastatisticalmodelinwhichtheunderlyingmodelisa
stochasticprocessthatisnotobservable(i.e.,hidden)andisassumed
tobeaMarkovprocesswhichcanbeobservedthroughanotherset
of stochasticprocessesthatproducethesequenceofobserved
symbols [33]. Thecurrentstatedependsona finitehistoryofprevious
states.Actually,inthisresearch,thecurrentstatedependsonlyonthe
previousstate.AnHMMmodelsasystemusinga finitesetofstates.
A hiddenstateisusedtorepresenteachoftheseparateactivities.
Each observableandhiddenstateisassociatedwithamultidimen-
sionalprobabilitydistributionoverasetofparameters.Theparameters
forthemodelarethefeaturesvaluesdescribedintheprevioussection.
Transitionsbetweenstatesaregovernedbytransitionprobabilities.
An HMMassignsprobabilityvaluesoverapotentiallyinfinitenumber
ofsequences.Butastheprobabilitiesvaluesmustsumtoone,the
distributiondescribedbyHMMisconstrained.Theconditionalprob-
abilitydistributionofanyhiddenstatedependsonlyonthevalueof
the precedinghiddenstate.Similarly,thevalueofanobservablestate
depends onlyonthevalueofthecurrenthiddenstate.
Consider asystemthathas N distinct states, fs1; s2;⋯; sNg, and
the actualstateattime t is qt ¼ si; 1rirN , theneachstatehas
M distinct observationsymbols,whichcanbedenotedas
fv1; v2;⋯; vMg. InthetheoryofHMM,theobservablevariable
ot ¼ vk; 1rk rM at time t depends onlyonthehiddenstate
variable si at thattime. Fig. 1. The smartapartmenttestbed.
H. Fangetal./ISATransactions53(2014)134–140 135
3. An HMMutilizesthreeprobabilitydistributions,the first isa
probability distributionoverinitialstates
πi ¼ Pðq1 ¼ siÞ ð1Þ
Second, thestatetransitionprobabilitydistributionrepresents
the probabilityoftransitioningfromstate i to state j, whichhasthe
form of
aij ¼ Pðqt ¼ sjjqt1 ¼ siÞ; 1ri; jrN ð2Þ
Third,theobservationprobabilitydistributionindicatesthe
probability thatthestate j wouldgenerateobservation ot ¼ vk
bjðkÞ ¼ Pðot ¼ vkjqt ¼ sjÞ; 1rjrN; 1rkrM ð3Þ
These distributionsareestimatedbasedontherelativefre-
quenciesofvisitedstatesandstatetransitionsobservedinthe
training data.
In thiscase,theViterbialgorithmcanbeappliedtoidentifythis
sequenceofhiddenstates,whichcomputethemostlikely
sequenceofhiddenstatesthatcorrespondtoasequenceof
observablesensorsevents.
The aimofViterbialgorithmareto find thesinglebeststate
sequence, fqn
1; qn
2;⋯; qnT
g, foragivenobservationsequence,
fo1; o2;⋯; oT g. Thebestscore,i.e.,thehighestprobability,alonga
single pathattime t is define as
δt ðiÞ ¼ max
q1;q2;⋯;qt 1
Pðq1q2⋯qt ¼ si; o1o2⋯otÞ ð4Þ
δt ðiÞ accounts forthe first t observationsandendinstate si, and
it canbesolvedinductivelyas
δtþ1ðjÞ ¼ ½ max
1rirN
δt ðiÞUaijUbjðotþ1Þ ð5Þ
where 1rjrN and 1rtrT1.
The initializationis
δ1ðiÞ ¼ πi Ubiðo1Þ; 1rirN ð6Þ
In eachrecursionofEq. (5), thelabelofahiddenstatewhichin
Eq. (4) is returnedby
ln
t ¼ arg max ½δt ðiÞ 1rirN ð7Þ
Once theprocedureisdone,thebesthiddenstatelabel
sequencecanbeobtainedas fln
1; ln
2;⋯; ln
T g, whichcorrespondsto
the besthiddenstatesequence fqn
1; qn
2;⋯; qnT
g.
ToimplementViterbialgorithm,eachactivityistreatedasa
hidden state.Sinceatotalof m activitiesarelabeledinthedataset
to berecognized,Viterbialgorithmincludes m hidden states.Each
hidden statedenotesoneofthe m modeled activities.Next,each
sensor istreatedasanobservablestate,becauseofeachused
sensor isobservableinthedataset.
Viterbialgorithmprocessesthesensorseventssequenceasa
continuous stream,andthenreturntheactivitylabel(hidden
node) withthehighestprobability,whichcorrespondstothemost
recentsensorevent.However,sinceonesensoreventmayhave
different probabilitiescorrespondingtodifferenthiddenstates
(activities), therefore,therecognitionaccuracyisnotdefinitely
100%.
In thisresearch,Viterbialgorithmusestherelativefrequencies
of featuresvaluesandtheactivitylabelsforthesampletrain-
ing datatolearnamappingfromadatapointdescriptiontoa
classification label.Itdeterminesactivitylabelsprobabilistically
based onthenumberofsensoreventofvariouskindsthatoccu-
rred duringtheactivity.Allactivitiesarerepresentedbyvarious
features includingthenumberofoccurringtimesofsensorID,
time ofday,dayofweek,previousactivityandactivitylength.
Actually,Viterbialgorithmusesthreeprobabilitydistributions:
the distributionoverinitialstates πi, thestatetransitionprob-
ability distribution aij, andtheobservationdistribution bjðkÞ. These
probabilitydistributionsareestimatedbasedontherelative
frequenciesofvisitedstatesandstatetransitionsobservedinthe
trainingdata.Givenasetoftrainingdata,Viterbialgorithmuses
the sensorsvaluesasparametersofahiddenMarkovmodel.Given
an inputsequenceofsensorseventsobservations,thegoalisto
find themostlikelysequenceofhiddenstates,oractivities,which
could havegeneratedtheobservedeventsequence,followingthe
calculation inEq. (7). Furthermore,thetrainingdataareusedto
learn thetransitionprobabilitiesbetweenstatesforthecorre-
sponding activitymodelandtolearnprobabilitydistributionsfor
the featuresvaluesofeachstateinthemodel.Forthis,theprior
probability(i.e.,thestartprobability)ofeverystatecanbe
calculated basedonthecollecteddata.Thepriorprobability
representsthebeliefaboutwhichstateofHMMisinwhenthe
first sensoreventisseen.Forastate(i.e.,activity) A, itiscalculated
as theratioofinstancesforwhichtheactivitylabelis A. The
transitionprobabilitywhichrepresentsthechangeofthestatein
the underlyinghiddenMarkovmodel,canalsobecalculated.For
anytwostates A and B, theprobabilityoftransitioningfromstate A
tostate B is calculatedastheratioofinstanceshavingactivitylabel
A followedbyactivitylabel B, tothetotalnumberofinstances.The
transitionprobabilitysignifies thelikelihoodoftransitioningfrom
a givenstatetoanyotherstateinthemodelandcapturesthe
temporalrelationshipbetweenthestates.Furthermore,theemis-
sion probabilityrepresentsthelikelihoodofobservingaparticular
sensor eventforagivenactivity.Thisiscalculatedby finding the
frequencyofeverysensoreventasobservedforeachactivity [29].
4. Testsresults
4.1.Trainingactivities
A totalof10activitieswereperformedintheCASASsmart
apartment bytwovolunteerstoprovidephysicaltrainingdatafor
the Viterbialgorithm.Theseactivitiesincludebothbasicandmore
complexADLsthatarefoundinclinicalquestionnaires.These
activitiesare:
(1) Bed_to_toilet(activity0,A0):transitionbetweenbedand
toilet inthenighttime.
(2) Breakfast(activity1,A1):theresidentshavebreakfast.
(3) Bed(activity2,A2):theactivityofsleepinginbed.
(4) C_work(activity3,A3):theactivityofresidentsworkinthe
office space.
(5) Dinner(activity4,A4):theresidentshavedinner.
(6) Laundry(activity5,A5):theresidentscleanclothesusingthe
laundry machine.
(7) Leave_home(activity6,A6):theactivityoftheresident
leavesthesmarthome.
(8) Lunch(activity7,A7):theresidentshavelunch.
(9) Night_wandering(activity8,A8):theactivityoftheresidents
wandersduringnighttimesleep.
(10)R_medicine(activity9,A9):theactivityoftheresidentstakes
medicine.
The datahavebeencollectedintheCASASsmartapartment
testbedfor55days,whichresultingintotal600instancesofthese
activitiesand647,485collectedmotionsensorsevents.The3-fold
crossvalidationisappliedinthisresearch.
4.2. Selectionsoftimefeaturevalues
In thiscase,theactivitylengthsizefeaturevalueisdefined as
the defaultvalue3.Thismeansthatthreeactivitylengthsize
rangesareused.However,thetimefeaturevaluesarecompared
H. Fangetal./ISATransactions53(2014)134–140 136