Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
d6f0fd37
Commit
d6f0fd37
authored
Oct 04, 2013
by
Davis King
Browse files
Added the ability to get the score in addition to the label out of the
multiclass_linear_decision_function.
parent
10dec05a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
dlib/svm/function.h
dlib/svm/function.h
+9
-2
dlib/svm/function_abstract.h
dlib/svm/function_abstract.h
+18
-0
No files found.
dlib/svm/function.h
View file @
d6f0fd37
...
@@ -778,7 +778,7 @@ namespace dlib
...
@@ -778,7 +778,7 @@ namespace dlib
unsigned
long
number_of_classes
(
unsigned
long
number_of_classes
(
)
const
{
return
labels
.
size
();
}
)
const
{
return
labels
.
size
();
}
result_type
operator
()
(
std
::
pair
<
result_type
,
scalar_type
>
predict
(
const
sample_type
&
x
const
sample_type
&
x
)
const
)
const
{
{
...
@@ -798,7 +798,14 @@ namespace dlib
...
@@ -798,7 +798,14 @@ namespace dlib
}
}
}
}
return
labels
[
best_idx
];
return
std
::
make_pair
(
labels
[
best_idx
],
best_val
);
}
result_type
operator
()
(
const
sample_type
&
x
)
const
{
return
predict
(
x
).
first
;
}
}
};
};
...
...
dlib/svm/function_abstract.h
View file @
d6f0fd37
...
@@ -927,6 +927,23 @@ namespace dlib
...
@@ -927,6 +927,23 @@ namespace dlib
this object)
this object)
!*/
!*/
std
::
pair
<
result_type
,
scalar_type
>
predict
(
const
sample_type
&
x
)
const
;
/*!
requires
- weights.size() > 0
- weights.nr() == number_of_classes() == b.size()
- if (x is a dense vector, i.e. a dlib::matrix) then
- is_vector(x) == true
- x.size() == weights.nc()
(i.e. it must be legal to multiply weights with x)
ensures
- Returns the predicted label for the x sample and also it's score.
In particular, it returns the following:
std::make_pair(labels[index_of_max(weights*x-b)], max(weights*x-b))
!*/
result_type
operator
()
(
result_type
operator
()
(
const
sample_type
&
x
const
sample_type
&
x
)
const
;
)
const
;
...
@@ -942,6 +959,7 @@ namespace dlib
...
@@ -942,6 +959,7 @@ namespace dlib
- Returns the predicted label for the x sample. In particular, it returns
- Returns the predicted label for the x sample. In particular, it returns
the following:
the following:
labels[index_of_max(weights*x-b)]
labels[index_of_max(weights*x-b)]
Or in other words, this function returns predict(x).first
!*/
!*/
};
};
...
...
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