Do some feature ranking

This commit is contained in:
Erica Fischer
2023-02-10 13:21:30 -08:00
parent 5c681e50d9
commit 1f396dbbb2
2 changed files with 12 additions and 2 deletions
+2
View File
@@ -289,11 +289,13 @@ void tilestats(std::map<std::string, layermap_entry> const &layermap1, size_t el
double yd = attribute.second.ysum / attribute.second.count;
double d = sqrt(xd * xd + yd * yd);
#if 0
printf("%s %0.6f", attribute.first.c_str(), d);
if (attribute.second.numeric_count != 0) {
printf(" %f %f", attribute.second.mean, sqrt(attribute.second.m2 / attribute.second.numeric_count));
}
printf("\n");
#endif
size_t val_count = attribute.second.sample_values.size();
if (val_count > max_tilestats_sample_values) {
+10 -2
View File
@@ -241,6 +241,8 @@ static int metacmp(const std::vector<long long> &keys1, const std::vector<long l
}
double get_interestingness(const serial_feature *sf, const std::map<std::string, layermap_entry> *merged_layermaps, std::string const &layername) {
double sum = 0;
auto layer = merged_layermaps->find(layername);
if (layer == merged_layermaps->end()) {
fprintf(stderr, "Can't find layer %s\n", layername.c_str());
@@ -272,12 +274,18 @@ double get_interestingness(const serial_feature *sf, const std::map<std::string,
// or somewhere in between for more reasonably categorical values.
double interestingness = sqrt(xd * xd + yd * yd);
printf("%f: %s %s\n", categoricality * interestingness, key.string_value.c_str(), sf->stringpool + sf->values[i] + 1);
// printf("%f: %s %s\n", categoricality * interestingness, key.string_value.c_str(), sf->stringpool + sf->values[i] + 1);
sum += categoricality * interestingness;
}
if (sf->stringpool[sf->values[i]] == mvt_double) {
double stddev = sqrt(tass->second.m2 / tass->second.numeric_count);
sum += fabs(atof(sf->stringpool + sf->values[i] + 1) - tass->second.mean) / stddev;
}
}
}
return 0;
return sum;
}
static mvt_value find_attribute_value(const serial_feature *sf, std::string key, const std::map<std::string, layermap_entry> *merged_layermaps, std::string const &layername) {