Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sgebreeg
RACER
Commits
577aca06
Commit
577aca06
authored
Dec 03, 2020
by
sgebreeg
Browse files
clean up
parent
107dba25
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/DecisionTree.cpp
View file @
577aca06
...
...
@@ -93,6 +93,7 @@ string DecisionTree::predictSingle(vector <string>& test, Node *treeRoot, Predic
}
Question
*
question
=
treeRoot
->
question
;
int
splitIndex
=
question
->
splitFeatureIndex
;
cout
<<
splitIndex
<<
endl
;
std
::
pair
<
int
,
double
>
featureInfoGain
(
question
->
splitFeatureIndex
,
treeRoot
->
informationGainFromParent
);
// value init
...
...
src/RandomForest.cpp
View file @
577aca06
...
...
@@ -236,6 +236,14 @@ vector <pair<int, double>> sort(map<int, double> &M, vector <string> test, vecto
cout
<<
features
[
it
.
first
]
<<
" is "
<<
test
[
it
.
first
]
<<
", "
;
count
++
;
}
// cout<<endl;
//
// cout<<"All explanation: ";
// for (auto &it : A) {
//
// cout << features[it.first] << " is " << test[it.first] << ", ";
//
// }
cout
<<
endl
;
return
A
;
}
...
...
src/main.cpp
View file @
577aca06
...
...
@@ -43,9 +43,9 @@ int main(int argc, char *argv[]) {
vector
<
vector
<
string
>>
datasetAsString
;
vector
<
FeatureType
>
featureTypes
;
vector
<
string
>
features
;
datasetAsString
=
parseDataToString
(
"../datasets/
mnis
t.data"
);
featureTypes
=
parseFeatureTypes
(
"../datasets/
mnis
t.featureTypes"
);
features
=
parseFeatures
(
"../datasets/
mnis
t.features"
);
datasetAsString
=
parseDataToString
(
"../datasets/
adul
t.data"
);
featureTypes
=
parseFeatureTypes
(
"../datasets/
adul
t.featureTypes"
);
features
=
parseFeatures
(
"../datasets/
adul
t.features"
);
//pick number of features to select for random sub-spacing
float
featureWeight
=
sqrt
(
features
.
size
())
/
features
.
size
();
...
...
@@ -81,11 +81,11 @@ int main(int argc, char *argv[]) {
cout
<<
endl
;
cout
<<
"********************* Forest accuracy *****************"
<<
endl
;
accuracyReport
report
=
randomForest
->
getAccuracy
(
datasetAsString
,
testingIdxs
);
accuracy
+=
report
.
accuracy
;
randomForest
->
printAccuracyReportFile
(
report
);
//
cout << "********************* Forest accuracy *****************" << endl;
//
accuracyReport report = randomForest->getAccuracy(datasetAsString,testingIdxs);
//
//
accuracy += report.accuracy;
//
randomForest->printAccuracyReportFile(report);
cout
<<
"**************** prediction with explanation ********** "
<<
endl
;
...
...
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