Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-103
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
2021-103
2021-103
Commits
cf1bc83a
Commit
cf1bc83a
authored
Nov 25, 2021
by
Karunathilake K. K. H. - IT18152456
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
7bf96a8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
0 deletions
+117
-0
FAMS/ROC/ROCSerializer.cs
FAMS/ROC/ROCSerializer.cs
+117
-0
No files found.
FAMS/ROC/ROCSerializer.cs
0 → 100644
View file @
cf1bc83a
/*
* Created by: Miguel Angel Medina Prez (miguel.medina.perez@gmail.com)
* Created:
* Comments by: Miguel Angel Medina Prez (miguel.medina.perez@gmail.com)
*/
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
namespace
PatternRecognition.ROC
{
/// <summary>
/// A utility class used to serialize and deserialize ROC curves.
/// </summary>
public
static
class
ROCSerializer
{
/// <summary>
/// Serialize the ROC curve to the specified file name.
/// </summary>
/// <param name="roc">
/// The points composing the ROC curve.
/// </param>
/// <param name="xLabel">
/// The label of horizontal axis in the ROC curve.
/// </param>
/// <param name="yLabel">
/// The label of vertical axis in the ROC curve.
/// </param>
/// <param name="matcherName">
/// The name of the fingerprint matcher.
/// </param>
/// <param name="fileName">
/// The file name where the curve will be serialized.
/// </param>
public
static
void
Serialize
(
List
<
ROCPoint
>
roc
,
string
xLabel
,
string
yLabel
,
string
matcherName
,
string
fileName
)
{
using
(
var
fs
=
new
StreamWriter
(
fileName
,
true
))
{
fs
.
WriteLine
(
"Matcher:;"
+
matcherName
);
fs
.
WriteLine
(
xLabel
+
";"
+
yLabel
);
foreach
(
ROCPoint
rocPoint
in
roc
)
fs
.
WriteLine
(
string
.
Format
(
"{0:f4};{1:f4}"
,
rocPoint
.
x
,
rocPoint
.
y
));
fs
.
Close
();
}
}
/// <summary>
/// Serialize the ROC curve to the specified <see cref="StreamWriter"/>.
/// </summary>
/// <param name="roc">
/// The points composing the ROC curve.
/// </param>
/// <param name="xLabel">
/// The label of horizontal axis in the ROC curve.
/// </param>
/// <param name="yLabel">
/// The label of vertical axis in the ROC curve.
/// </param>
/// <param name="matcherName">
/// The name of the fingerprint matcher.
/// </param>
/// <param name="fs">
/// The <see cref="StreamWriter"/> where the curve will be serialized.
/// </param>
public
static
void
Serialize
(
List
<
ROCPoint
>
roc
,
string
xLabel
,
string
yLabel
,
string
matcherName
,
StreamWriter
fs
)
{
fs
.
WriteLine
(
"Matcher:;"
+
matcherName
);
fs
.
WriteLine
(
xLabel
+
";"
+
yLabel
+
";Threshold"
);
foreach
(
ROCPoint
rocPoint
in
roc
)
fs
.
WriteLine
(
string
.
Format
(
"{0:f4};{1:f4};{2:f4}"
,
rocPoint
.
x
,
rocPoint
.
y
,
rocPoint
.
matchingValue
));
fs
.
Close
();
}
/// <summary>
/// Deserialize the ROC curve from the specified file name.
/// </summary>
/// <param name="fileName">
/// The file name where the ROC curve is serialized.
/// </param>
/// <param name="xLabel">
/// The label of horizontal axis in the ROC curve.
/// </param>
/// <param name="yLabel">
/// The label of vertical axis in the ROC curve.
/// </param>
/// <param name="matcherName">
/// The name of the fingerprint matcher.
/// </param>
/// <returns>
/// The points composing the ROC curve.
/// </returns>
public
static
List
<
ROCPoint
>
Deserialize
(
string
fileName
,
out
string
xLabel
,
out
string
yLabel
,
out
string
matcherName
)
{
var
roc
=
new
List
<
ROCPoint
>();
using
(
var
sr
=
new
StreamReader
(
fileName
))
{
matcherName
=
sr
.
ReadLine
();
var
line
=
sr
.
ReadLine
();
var
splitStringArray
=
new
string
[
1
]
{
";"
};
var
members
=
line
.
Split
(
splitStringArray
,
StringSplitOptions
.
None
);
xLabel
=
members
[
0
];
yLabel
=
members
[
1
];
// Read lines from the file until the end of the file is reached.
while
((
line
=
sr
.
ReadLine
())
!=
null
)
{
members
=
line
.
Split
(
splitStringArray
,
StringSplitOptions
.
None
);
var
rocPoint
=
new
ROCPoint
(
Convert
.
ToDouble
(
members
[
0
]),
Convert
.
ToDouble
(
members
[
1
]),
Convert
.
ToDouble
(
members
[
2
]));
roc
.
Add
(
rocPoint
);
}
sr
.
Close
();
}
return
roc
;
}
}
}
\ No newline at end of file
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