This is an automated email from the git hooks/post-receive script. sebastic-guest pushed a commit to branch upstream-master in repository pktools.
commit 3a5b4d8fe102c0f5178056420154ddef69a367f3 Author: Pieter Kempeneers <kempe...@gmail.com> Date: Mon Jun 2 20:38:04 2014 +0200 working on pkfssvm, label names via global ConfusionMatrix seems not to work --- src/algorithms/FeatureSelector.h | 5 ++--- src/apps/pkdiff.cc | 3 +++ src/apps/pkfsann.cc | 8 ++++---- src/apps/pkfssvm.cc | 13 +++++++------ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/algorithms/FeatureSelector.h b/src/algorithms/FeatureSelector.h index b57771e..44ef7e5 100644 --- a/src/algorithms/FeatureSelector.h +++ b/src/algorithms/FeatureSelector.h @@ -38,7 +38,7 @@ class FeatureSelector template<class T> double forwardUnivariate(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures, short verbose=0); template<class T> double forward(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures, short verbose=0); template<class T> double backward(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int minFeatures, short verbose=0); - template<class T> double floating(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures=0, short verbose=0); + template<class T> double floating(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures=0, double epsilon=0.001, short verbose=0); template<class T> double bruteForce(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures=0, short verbose=0); private: @@ -148,8 +148,7 @@ template<class T> double FeatureSelector::backward(std::vector< Vector2d<T> >& v } //floating search -template<class T> double FeatureSelector::floating(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures, short verbose){ - double epsilon=0.001; +template<class T> double FeatureSelector::floating(std::vector< Vector2d<T> >& v, double (*getCost)(const std::vector< Vector2d<T> >&), std::list<int>& subset, int maxFeatures, double epsilon, short verbose){ std::vector<T> cost; int maxLevels=v[0][0].size(); if(maxFeatures<1) diff --git a/src/apps/pkdiff.cc b/src/apps/pkdiff.cc index f07d617..2eb469c 100644 --- a/src/apps/pkdiff.cc +++ b/src/apps/pkdiff.cc @@ -341,6 +341,7 @@ int main(int argc, char *argv[]) referenceValue=readFeature->GetFieldAsInteger(readFeature->GetFieldIndex(labelref_opt[0].c_str())); if(verbose_opt[0]) cout << "reference value: " << referenceValue << endl; + bool pixelFlagged=false; bool maskFlagged=false; for(int iflag=0;iflag<nodata_opt.size();++iflag){ @@ -365,6 +366,7 @@ int main(int argc, char *argv[]) //check if i_centre is out of bounds if(static_cast<int>(i_centre)<0||static_cast<int>(i_centre)>=inputReader.nrOfCol()) continue; + if(output_opt.size()){ writeFeature = OGRFeature::CreateFeature(writeLayer->GetLayerDefn()); assert(readFeature); @@ -442,6 +444,7 @@ int main(int argc, char *argv[]) } } //at this point we know the values for the entire window + if(homogeneous_opt[0]){//only centre pixel int j=j_centre; int i=i_centre; diff --git a/src/apps/pkfsann.cc b/src/apps/pkfsann.cc index 51d8b98..ea23cc6 100644 --- a/src/apps/pkfsann.cc +++ b/src/apps/pkfsann.cc @@ -565,19 +565,19 @@ int main(int argc, char *argv[]) list<int> subset;//set of selected features (levels) for each class combination FeatureSelector selector; try{ - if(maxFeatures==nFeatures){ + if(maxFeatures>=nFeatures){ subset.clear(); for(int ifeature=0;ifeature<nFeatures;++ifeature) subset.push_back(ifeature); cost=getCost(trainingFeatures); } else{ - while(fabs(cost-previousCost)>epsilon_cost_opt[0]){ + while(fabs(cost-previousCost)>=epsilon_cost_opt[0]){ previousCost=cost; switch(selMap[selector_opt[0]]){ case(SFFS): subset.clear();//needed to clear in case of floating and brute force search - cost=selector.floating(trainingFeatures,&getCost,subset,maxFeatures,verbose_opt[0]); + cost=selector.floating(trainingFeatures,&getCost,subset,maxFeatures,epsilon_cost_opt[0],verbose_opt[0]); break; case(SFS): cost=selector.forward(trainingFeatures,&getCost,subset,maxFeatures,verbose_opt[0]); @@ -594,7 +594,7 @@ int main(int argc, char *argv[]) exit(1); break; } - if(verbose_opt[0]){ + if(verbose_opt[0]>1){ std::cout << "cost: " << cost << std::endl; std::cout << "previousCost: " << previousCost << std::endl; std::cout << std::setprecision(12) << "cost-previousCost: " << cost - previousCost << " ( " << epsilon_cost_opt[0] << ")" << std::endl; diff --git a/src/apps/pkfssvm.cc b/src/apps/pkfssvm.cc index 5dfccf6..2a6b798 100644 --- a/src/apps/pkfssvm.cc +++ b/src/apps/pkfssvm.cc @@ -176,8 +176,9 @@ double getCost(const vector<Vector2d<float> > &trainingFeatures) x_test[nFeatures].index=-1; double predict_label=0; //todo: make distinction between svm_predict and svm_predict_probability? - assert(svm_check_probability_model(svm)); - predict_label = svm_predict_probability(svm,x_test,&(result[0])); + // assert(svm_check_probability_model(svm)); + // predict_label = svm_predict_probability(svm,x_test,&(result[0])); + predict_label = svm_predict(svm,x_test); string refClassName=nameVector[iclass]; string className=nameVector[static_cast<short>(predict_label)]; if(classValueMap.size()) @@ -591,19 +592,19 @@ int main(int argc, char *argv[]) list<int> subset;//set of selected features (levels) for each class combination FeatureSelector selector; try{ - if(maxFeatures==nFeatures){ + if(maxFeatures>=nFeatures){ subset.clear(); for(int ifeature=0;ifeature<nFeatures;++ifeature) subset.push_back(ifeature); cost=getCost(trainingFeatures); } else{ - while(fabs(cost-previousCost)>epsilon_cost_opt[0]){ + while(fabs(cost-previousCost)>=epsilon_cost_opt[0]){ previousCost=cost; switch(selMap[selector_opt[0]]){ case(SFFS): subset.clear();//needed to clear in case of floating and brute force search - cost=selector.floating(trainingFeatures,&getCost,subset,maxFeatures,verbose_opt[0]); + cost=selector.floating(trainingFeatures,&getCost,subset,maxFeatures,epsilon_cost_opt[0],verbose_opt[0]); break; case(SFS): cost=selector.forward(trainingFeatures,&getCost,subset,maxFeatures,verbose_opt[0]); @@ -620,7 +621,7 @@ int main(int argc, char *argv[]) exit(1); break; } - if(verbose_opt[0]){ + if(verbose_opt[0]>1){ std::cout << "cost: " << cost << std::endl; std::cout << "previousCost: " << previousCost << std::endl; std::cout << std::setprecision(12) << "cost-previousCost: " << cost - previousCost << " ( " << epsilon_cost_opt[0] << ")" << std::endl; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel