Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
rapid-mix
RapidLib
Commits
6776aaf1
Commit
6776aaf1
authored
Sep 26, 2017
by
mzed
Browse files
seriesClassification: check against one label
parent
bc883960
Changes
3
Hide whitespace changes
Inline
Side-by-side
RapidAPI/RapidAPI/main.cpp
View file @
6776aaf1
...
...
@@ -241,7 +241,11 @@ int main(int argc, const char * argv[]) {
assert
(
myDTW
.
run
(
seriesTwo
)
==
"second series"
);
//std::cout << myDTW.getCosts()[0] << std::endl;
//std::cout << myDTW.getCosts()[1] << std::endl;
//testing match against single label
assert
(
myDTW
.
run
(
seriesOne
,
"second series"
)
==
19.325403217417502
);
//Training set stats
assert
(
myDTW
.
getMaxLength
()
==
5
);
assert
(
myDTW
.
getMinLength
()
==
4
);
assert
(
myDTW
.
getMaxLength
(
"first series"
)
==
5
);
...
...
src/seriesClassification.cpp
View file @
6776aaf1
...
...
@@ -83,6 +83,23 @@ std::string seriesClassification<T>::run(const std::vector<std::vector<T>> &inpu
return
allTrainingSeries
[
closestSeries
].
label
;
};
template
<
typename
T
>
T
seriesClassification
<
T
>::
run
(
const
std
::
vector
<
std
::
vector
<
T
>>
&
inputSeries
,
std
::
string
label
)
{
int
closestSeries
=
0
;
allCosts
.
clear
();
T
lowestCost
=
std
::
numeric_limits
<
T
>::
max
();
for
(
int
i
=
0
;
i
<
allTrainingSeries
.
size
();
++
i
)
{
if
(
allTrainingSeries
[
i
].
label
==
label
)
{
T
currentCost
=
fastDTW
<
T
>::
getCost
(
inputSeries
,
allTrainingSeries
[
i
].
input
,
SEARCH_RADIUS
);
allCosts
.
push_back
(
currentCost
);
if
(
currentCost
<
lowestCost
)
{
lowestCost
=
currentCost
;
closestSeries
=
i
;
}
}
}
return
lowestCost
;
};
template
<
typename
T
>
std
::
vector
<
T
>
seriesClassification
<
T
>::
getCosts
()
{
...
...
src/seriesClassification.h
View file @
6776aaf1
...
...
@@ -24,7 +24,10 @@ public:
bool
train
(
const
std
::
vector
<
trainingSeries
<
T
>
>
&
seriesSet
);
void
reset
();
std
::
string
run
(
const
std
::
vector
<
std
::
vector
<
T
>>
&
inputSeries
);
T
run
(
const
std
::
vector
<
std
::
vector
<
T
>>
&
inputSeries
,
std
::
string
label
);
std
::
vector
<
T
>
getCosts
();
int
getMinLength
();
...
...
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