Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-045
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2020-045
2020-045
Commits
0edc2324
Commit
0edc2324
authored
Sep 16, 2020
by
Boteju W.J.M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
09/16-Django
parent
bad59434
Pipeline
#1494
failed with stages
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
147 additions
and
105 deletions
+147
-105
WalkingPatternRecognition/FeatureVectorsRestTrain.csv
WalkingPatternRecognition/FeatureVectorsRestTrain.csv
+3
-0
WalkingPatternRecognition/Readings.csv
WalkingPatternRecognition/Readings.csv
+4
-13
WalkingPatternRecognition/TrainingRestReadings.csv
WalkingPatternRecognition/TrainingRestReadings.csv
+6
-0
WalkingPatternRecognition/mobileapp/__pycache__/urls.cpython-38.pyc
...ternRecognition/mobileapp/__pycache__/urls.cpython-38.pyc
+0
-0
WalkingPatternRecognition/mobileapp/__pycache__/views.cpython-38.pyc
...ernRecognition/mobileapp/__pycache__/views.cpython-38.pyc
+0
-0
WalkingPatternRecognition/mobileapp/urls.py
WalkingPatternRecognition/mobileapp/urls.py
+3
-1
WalkingPatternRecognition/mobileapp/views.py
WalkingPatternRecognition/mobileapp/views.py
+131
-91
No files found.
WalkingPatternRecognition/FeatureVectorsRestTrain.csv
0 → 100644
View file @
0edc2324
AccXmin,AccYmin,AccZmin,AccXmax,AccYmax,AccZmax,AccXmean,AccYmean,AccZmean,GyrXmin,GyrYmin,GyrZmin,GyrXmax,GyrYmax,GyrZmax,GyrXmean,GyrYmean,GyrZmean,StartTime,EndTime
-0.02,-0.0,-0.0,-0.0,-0.0,-0.0,-0.0006451612903225806,0.0,0.0,-0.01,-0.01,-0.01,-0.01,-0.01,-0.01,-0.009354838709677422,-0.009354838709677422,-0.009354838709677422,2020-09-16 17:53:09.668788,2020-09-16 17:54:09.686843
-0.02,0.0,0.0,1.98,0.0,0.0,0.3926666666666669,0.0,0.0,-0.01,-0.01,-0.01,0.0,0.0,0.0,-0.0006666666666666666,-0.0006666666666666666,-0.0006666666666666666,2020-09-16 18:18:32.209880,2020-09-16 18:19:30.213294
WalkingPatternRecognition/Readings.csv
View file @
0edc2324
timestamp,accelerometer_X,accelerometer_Y,accelerometer_Z,gyroscope_X,gyroscope_Y,gyroscope_Z
2020-09-16 17:03:22.136336,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:24.134330,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:26.129740,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:28.131721,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:30.149266,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:32.144732,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:34.413466,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:36.130066,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:38.165661,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:40.144913,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:42.127917,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:44.140344,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:03:46.128084,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:41:39.477881,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:41:41.476489,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:41:43.468825,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
2020-09-16 17:41:45.619212,-0.00,-0.00,-0.00,-0.01,-0.01,-0.01
WalkingPatternRecognition/TrainingRestReadings.csv
0 → 100644
View file @
0edc2324
timestamp,accelerometer_X,accelerometer_Y,accelerometer_Z,gyroscope_X,gyroscope_Y,gyroscope_Z
2020-09-16 18:19:34.220893,0.05,0.00,0.00,0.00,0.00,0.00
2020-09-16 18:19:36.217454,0.05,0.00,0.00,0.00,0.00,0.00
2020-09-16 18:19:38.206760,0.05,0.00,0.00,0.00,0.00,0.00
2020-09-16 18:19:40.202189,0.02,0.00,0.00,0.00,0.00,0.00
2020-09-16 18:19:42.205321,0.02,0.00,0.00,0.00,0.00,0.00
WalkingPatternRecognition/mobileapp/__pycache__/urls.cpython-38.pyc
View file @
0edc2324
No preview for this file type
WalkingPatternRecognition/mobileapp/__pycache__/views.cpython-38.pyc
View file @
0edc2324
No preview for this file type
WalkingPatternRecognition/mobileapp/urls.py
View file @
0edc2324
...
...
@@ -44,5 +44,7 @@ urlpatterns = [
path
(
'highlightsPerYear'
,
views
.
highlightsPerYear
),
# getting the readings
path
(
'readings'
,
views
.
readings
)
path
(
'readings'
,
views
.
readings
),
path
(
'trainingReadings'
,
views
.
trainingReadings
)
]
WalkingPatternRecognition/mobileapp/views.py
View file @
0edc2324
...
...
@@ -610,7 +610,7 @@ def getReadings():
ReadingsArray
.
append
(
reading
.
split
(
":"
))
i
=
i
+
1
finalArray
=
obtainReadings
(
ReadingsArray
)
print
(
finalArray
)
#
print(finalArray)
file
=
open
(
"Readings.csv"
)
numline
=
len
(
file
.
readlines
())
...
...
@@ -667,16 +667,11 @@ class Main:
gd1
=
GetData
(
dataset
)
f
=
FeatureExtraction
(
gd1
)
if
'activity'
in
data
.
columns
:
print
(
"For Training "
)
FeatureVector
=
f
.
getSmallFeatureSingle
(
dataset
)
d
.
append_list_as_row
(
'FeatureVectorTrain.csv'
,
FeatureVector
)
else
:
FeatureVector
=
f
.
getSmallTestFeatureSingle
(
dataset
)
append_list_as_row
(
'FeatureVectorTest.csv'
,
FeatureVector
)
r
=
Data
(
'FeatureVectorTest.csv'
)
predictingActivity
=
r
.
ReadData
()
predictedActivity
=
Test
(
predictingActivity
)
FeatureVector
=
f
.
getFeatureSingle
(
dataset
)
append_list_as_row
(
'FeatureVectorTest.csv'
,
FeatureVector
)
r
=
Data
(
'FeatureVectorTest.csv'
)
predictingActivity
=
r
.
ReadData
()
predictedActivity
=
Test
(
predictingActivity
)
else
:
break
i
=
i
+
30
...
...
@@ -711,24 +706,42 @@ class GetData:
def
__init__
(
self
,
data
):
self
.
data
=
data
def
getX
(
self
,
data
):
def
get
Acc
X
(
self
,
data
):
X
=
[]
for
i
,
row
in
data
.
iterrows
():
X
.
append
(
float
(
data
.
xs
(
i
)[
'accelerometer_X'
]))
return
X
def
getY
(
self
,
data
):
def
get
Acc
Y
(
self
,
data
):
Y
=
[]
for
i
,
row
in
data
.
iterrows
():
Y
.
append
(
float
(
data
.
xs
(
i
)[
'accelerometer_Y'
]))
return
Y
def
getZ
(
self
,
data
):
def
get
Acc
Z
(
self
,
data
):
Z
=
[]
for
i
,
row
in
data
.
iterrows
():
Z
.
append
(
float
(
data
.
xs
(
i
)[
'accelerometer_Z'
]))
return
Z
def
getGyrX
(
self
,
data
):
X
=
[]
for
i
,
row
in
data
.
iterrows
():
X
.
append
(
float
(
data
.
xs
(
i
)[
'gyroscope_X'
]))
return
X
def
getGyrY
(
self
,
data
):
Y
=
[]
for
i
,
row
in
data
.
iterrows
():
Y
.
append
(
float
(
data
.
xs
(
i
)[
'gyroscope_Y'
]))
return
Y
def
getGyrZ
(
self
,
data
):
Z
=
[]
for
i
,
row
in
data
.
iterrows
():
Z
.
append
(
float
(
data
.
xs
(
i
)[
'gyroscope_Z'
]))
return
Z
def
getMagnitude
(
self
,
data
):
Magnitudes
=
[]
for
i
,
row
in
data
.
iterrows
():
...
...
@@ -801,61 +814,42 @@ class FeatureExtraction:
RMSTotal
+=
(
i
**
2
)
return
((
RMSTotal
)
**
0.5
)
def
most_frequent
(
self
,
List
):
counter
=
0
num
=
List
[
0
]
for
i
in
List
:
curr_frequency
=
List
.
count
(
i
)
if
(
curr_frequency
>
counter
):
counter
=
curr_frequency
num
=
i
return
num
def
getSmallFeatureSingle
(
self
,
list
):
def
getSmallTestFeatureSingle
(
self
,
list
):
d
=
GetData
(
list
)
X
=
d
.
getX
(
list
)
Y
=
d
.
getY
(
list
)
Z
=
d
.
getZ
(
list
)
Activities
=
d
.
getActivities
(
list
)
AccX
=
d
.
getAccX
(
list
)
AccY
=
d
.
getAccY
(
list
)
AccZ
=
d
.
getAccZ
(
list
)
fe
=
FeatureExtraction
(
list
)
feature
=
[]
feature
.
append
(
fe
.
MinimumPeak
(
X
))
feature
.
append
(
fe
.
MinimumPeak
(
Y
))
feature
.
append
(
fe
.
MinimumPeak
(
Z
))
feature
.
append
(
fe
.
MaximumPeak
(
X
))
feature
.
append
(
fe
.
MaximumPeak
(
Y
))
feature
.
append
(
fe
.
MaximumPeak
(
Z
))
feature
.
append
(
fe
.
Mean
(
X
))
feature
.
append
(
fe
.
Mean
(
Y
))
feature
.
append
(
fe
.
Mean
(
Z
))
feature
.
append
(
np
.
bincount
(
Activities
)
.
argmax
())
print
(
"Feature Vector
\n
"
,
feature
,
"
\n\n
"
)
return
feature
GyrX
=
d
.
getGyrX
(
list
)
GyrY
=
d
.
getGyrY
(
list
)
GyrZ
=
d
.
getGyrZ
(
list
)
def
getSmallTestFeatureSingle
(
self
,
list
):
d
=
GetData
(
list
)
X
=
d
.
getX
(
list
)
Y
=
d
.
getY
(
list
)
Z
=
d
.
getZ
(
list
)
times
=
d
.
getStartAndEndTime
(
list
)
fe
=
FeatureExtraction
(
list
)
feature
=
[]
feature
.
append
(
fe
.
MinimumPeak
(
X
))
feature
.
append
(
fe
.
MinimumPeak
(
Y
))
feature
.
append
(
fe
.
MinimumPeak
(
Z
))
feature
.
append
(
fe
.
MaximumPeak
(
X
))
feature
.
append
(
fe
.
MaximumPeak
(
Y
))
feature
.
append
(
fe
.
MaximumPeak
(
Z
))
feature
.
append
(
fe
.
Mean
(
X
))
feature
.
append
(
fe
.
Mean
(
Y
))
feature
.
append
(
fe
.
Mean
(
Z
))
feature
.
append
(
fe
.
MinimumPeak
(
AccX
))
feature
.
append
(
fe
.
MinimumPeak
(
AccY
))
feature
.
append
(
fe
.
MinimumPeak
(
AccZ
))
feature
.
append
(
fe
.
MaximumPeak
(
AccX
))
feature
.
append
(
fe
.
MaximumPeak
(
AccY
))
feature
.
append
(
fe
.
MaximumPeak
(
AccZ
))
feature
.
append
(
fe
.
Mean
(
AccX
))
feature
.
append
(
fe
.
Mean
(
AccY
))
feature
.
append
(
fe
.
Mean
(
AccZ
))
feature
.
append
(
fe
.
MinimumPeak
(
GyrX
))
feature
.
append
(
fe
.
MinimumPeak
(
GyrY
))
feature
.
append
(
fe
.
MinimumPeak
(
GyrZ
))
feature
.
append
(
fe
.
MaximumPeak
(
GyrX
))
feature
.
append
(
fe
.
MaximumPeak
(
GyrY
))
feature
.
append
(
fe
.
MaximumPeak
(
GyrZ
))
feature
.
append
(
fe
.
Mean
(
GyrX
))
feature
.
append
(
fe
.
Mean
(
GyrY
))
feature
.
append
(
fe
.
Mean
(
GyrZ
))
feature
.
append
(
times
[
0
])
feature
.
append
(
times
[
1
])
...
...
@@ -864,37 +858,13 @@ class FeatureExtraction:
def
getFeatureSingle
(
self
,
list
):
d
=
GetData
(
list
)
X
=
d
.
getX
(
list
)
Y
=
d
.
getY
(
list
)
Z
=
d
.
getZ
(
list
)
Magnitudes
=
d
.
getMagnitude
(
list
)
Activities
=
d
.
getActivities
(
list
)
X
=
d
.
getAccX
(
list
)
Y
=
d
.
getAccY
(
list
)
Z
=
d
.
getAccZ
(
list
)
times
=
d
.
getStartAndEndTime
(
list
)
fe
=
FeatureExtraction
(
list
)
feature
=
[]
feature
.
append
(
fe
.
Mean
(
X
))
feature
.
append
(
fe
.
Mean
(
Y
))
feature
.
append
(
fe
.
Mean
(
Z
))
feature
.
append
(
fe
.
median
(
X
))
feature
.
append
(
fe
.
median
(
Y
))
feature
.
append
(
fe
.
median
(
Z
))
feature
.
append
(
fe
.
Variance
(
X
))
feature
.
append
(
fe
.
Variance
(
Y
))
feature
.
append
(
fe
.
Variance
(
Z
))
feature
.
append
(
fe
.
StandardDeviation
(
X
))
feature
.
append
(
fe
.
StandardDeviation
(
Y
))
feature
.
append
(
fe
.
StandardDeviation
(
Z
))
feature
.
append
(
fe
.
RMS
(
X
))
feature
.
append
(
fe
.
RMS
(
Y
))
feature
.
append
(
fe
.
RMS
(
Z
))
feature
.
append
(
fe
.
Energy
(
X
))
feature
.
append
(
fe
.
Energy
(
Y
))
feature
.
append
(
fe
.
Energy
(
Z
))
feature
.
append
(
fe
.
Mean
(
Magnitudes
))
feature
.
append
(
np
.
bincount
(
Activities
)
.
argmax
())
feature
=
[
fe
.
MinimumPeak
(
X
),
fe
.
MinimumPeak
(
Y
),
fe
.
MinimumPeak
(
Z
),
fe
.
MaximumPeak
(
X
),
fe
.
MaximumPeak
(
Y
),
fe
.
MaximumPeak
(
Z
),
fe
.
Mean
(
X
),
fe
.
Mean
(
Y
),
fe
.
Mean
(
Z
),
times
[
0
],
times
[
1
]]
print
(
"Feature Vector
\n
"
,
feature
,
"
\n\n
"
)
return
feature
...
...
@@ -1115,5 +1085,75 @@ def getBreedActivityData(breed):
return
value
# TRAINING READINGS
def
trainingReadings
(
request
):
sched
=
BackgroundScheduler
()
# seconds can be replaced with minutes, hours, or days
sched
.
add_job
(
getTrainingReadings
,
'interval'
,
seconds
=
2
)
sched
.
start
()
return
JsonResponse
({
'data'
:
"Training Data obtained"
},
safe
=
False
,
status
=
status
.
HTTP_201_CREATED
)
@
csrf_exempt
def
getTrainingReadings
():
ReadingsArray
=
[]
responseObtained
=
requests
.
get
(
'http://192.168.1.36/getReadings'
)
result
=
responseObtained
.
text
Array
=
result
.
split
(
","
)
length
=
len
(
Array
)
i
=
0
while
i
<
length
:
reading
=
Array
[
i
]
ReadingsArray
.
append
(
reading
.
split
(
":"
))
i
=
i
+
1
finalArray
=
obtainReadings
(
ReadingsArray
)
print
(
finalArray
)
file
=
open
(
"TrainingRestReadings.csv"
)
numline
=
len
(
file
.
readlines
())
if
numline
<
31
:
append_list_as_row
(
'TrainingRestReadings.csv'
,
finalArray
)
else
:
# trying to get the prediction
MainTraining
()
with
open
(
"TrainingRestReadings.csv"
,
'r'
)
as
f
:
with
open
(
"TrainingRestReadings.csv"
,
'w'
)
as
f1
:
next
(
f
,
None
)
for
line
in
f
:
f1
.
close
()
append_list_as_row
(
'TrainingRestReadings.csv'
,
[
'timestamp'
,
'accelerometer_X'
,
'accelerometer_Y'
,
'accelerometer_Z'
,
'gyroscope_X'
,
'gyroscope_Y'
,
'gyroscope_Z'
])
return
HttpResponse
(
response
)
class
MainTraining
:
def
__init__
(
self
):
print
(
"For Training "
)
d
=
Data
(
'TrainingRestReadings.csv'
)
data
=
d
.
ReadData
()
i
,
j
=
0
,
0
length
=
len
(
data
)
while
i
<=
length
:
Index
=
[]
count
=
i
+
30
if
j
<
length
:
while
j
<=
count
:
Index
.
append
(
j
)
j
=
j
+
1
print
(
Index
)
fIndex
,
lIndex
=
Index
[
0
],
Index
[
-
1
]
dataset
=
data
.
iloc
[
fIndex
:
lIndex
+
1
]
gd1
=
GetData
(
dataset
)
f
=
FeatureExtraction
(
gd1
)
FeatureVector
=
f
.
getSmallTestFeatureSingle
(
dataset
)
d
.
append_list_as_row
(
'FeatureVectorsRestTrain.csv'
,
FeatureVector
)
else
:
break
i
=
i
+
30
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment