Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Emmanuel Hebrard
Blossom
Commits
b61665a8
Commit
b61665a8
authored
Jul 29, 2020
by
Louis Jean
Browse files
WIP dataset
parent
d3f677fe
Changes
4
Hide whitespace changes
Inline
Side-by-side
code/src/include/Backtrack.hpp
View file @
b61665a8
...
...
@@ -75,13 +75,12 @@ private:
//@{
/// Argument
Wood
&
wood
;
//
Data
S
et &data;
Data
s
et
&
data
;
int
num_feature
;
// size_t numExample() const;
// size_t numExample[2];
DTOptions
&
options
;
vector
<
vector
<
int
>>
example
[
2
];
vector
<
int
>
relevant_features
;
dynamic_bitset
<>
feature_set
;
...
...
@@ -317,12 +316,9 @@ private:
public:
ErrorPolicy
<
E_t
>
error_policy
;
vector
<
instance
>
dataset
[
2
];
vector
<
dynamic_bitset
<>>
reverse_dataset
[
2
];
/*!@name Constructors*/
//@{
explicit
BacktrackingAlgorithm
(
Wood
&
w
,
DTOptions
&
o
);
explicit
BacktrackingAlgorithm
(
Wood
&
w
,
Dataset
&
dataset
,
DTOptions
&
o
);
void
setData
(
const
DataSet
&
data
);
void
setReverse
();
void
seed
(
const
int
s
);
...
...
code/src/include/Dataset.hpp
0 → 100644
View file @
b61665a8
#include
<vector>
#include
<boost/dynamic_bitset.hpp>
using
namespace
boost
;
using
namespace
std
;
namespace
primer
{
typedef
dynamic_bitset
<>
instance
;
class
Dataset
{
public:
/// List of positive features
vector
<
vector
<
int
>>
example
[
2
];
/// Dataset as a bitset
vector
<
instance
>
dataset
[
2
];
/// For each feature, does the example has it?
vector
<
dynamic_bitset
<>>
reverse_dataset
[
2
];
};
template
<
typename
T
>
class
WeightedDataset
:
public
Dataset
{
public:
vector
<
T
>
weights
[
2
];
};
}
code/src/lib/Backtrack.cpp
View file @
b61665a8
...
...
@@ -117,8 +117,9 @@ void WeightedError<E_t>::clear_examples(Algo &algo) {
template
<
template
<
typename
>
class
ErrorPolicy
,
typename
E_t
>
BacktrackingAlgorithm
<
ErrorPolicy
,
E_t
>::
BacktrackingAlgorithm
(
Wood
&
w
,
Dataset
&
dataset
,
DTOptions
&
opt
)
:
wood
(
w
),
options
(
opt
)
{
:
wood
(
w
),
dataset
(
dataset
),
options
(
opt
)
{
// start_time = cpu_time();
...
...
@@ -181,23 +182,23 @@ void BacktrackingAlgorithm<ErrorPolicy, E_t>::setReverse() {
}
template
<
template
<
typename
>
class
ErrorPolicy
,
typename
E_t
>
void
BacktrackingAlgorithm
<
ErrorPolicy
,
E_t
>::
setData
(
const
DataSet
&
d
ata
)
{
num_feature
=
static_cast
<
int
>
(
d
ata
.
numFeature
());
void
BacktrackingAlgorithm
<
ErrorPolicy
,
E_t
>::
setData
(
const
DataSet
&
d
set
)
{
num_feature
=
static_cast
<
int
>
(
d
set
.
numFeature
());
f_error
.
resize
(
num_feature
,
1
);
f_entropy
.
resize
(
num_feature
,
1
);
f_gini
.
resize
(
num_feature
,
1
);
for
(
int
y
{
0
};
y
<
2
;
++
y
)
{
dataset
[
y
].
resize
(
d
ata
.
example
[
y
].
count
());
example
[
y
].
resize
(
d
ata
.
example
[
y
].
count
());
dataset
[
y
].
resize
(
d
set
.
example
[
y
].
count
());
example
[
y
].
resize
(
d
set
.
example
[
y
].
count
());
auto
k
{
0
};
for
(
auto
i
:
d
ata
.
example
[
y
])
{
for
(
auto
i
:
d
set
.
example
[
y
])
{
// cout << k << ":";
dataset
[
y
][
k
].
resize
(
num_feature
);
dataset
[
y
][
k
]
=
d
ata
[
i
];
dataset
[
y
][
k
]
=
d
set
[
i
];
for
(
auto
j
{
0
};
j
<
num_feature
;
++
j
)
if
(
d
ata
.
hasFeature
(
i
,
j
))
{
if
(
d
set
.
hasFeature
(
i
,
j
))
{
example
[
y
][
k
].
push_back
(
j
);
// cout << " " << j;
}
...
...
code/src/lib/Dataset.cpp
0 → 100644
View file @
b61665a8
#include
"Dataset.hpp"
namespace
primer
{
}
Write
Preview
Supports
Markdown
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