mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Do some feature ranking
This commit is contained in:
@@ -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 yd = attribute.second.ysum / attribute.second.count;
|
||||||
double d = sqrt(xd * xd + yd * yd);
|
double d = sqrt(xd * xd + yd * yd);
|
||||||
|
|
||||||
|
#if 0
|
||||||
printf("%s %0.6f", attribute.first.c_str(), d);
|
printf("%s %0.6f", attribute.first.c_str(), d);
|
||||||
if (attribute.second.numeric_count != 0) {
|
if (attribute.second.numeric_count != 0) {
|
||||||
printf(" %f %f", attribute.second.mean, sqrt(attribute.second.m2 / attribute.second.numeric_count));
|
printf(" %f %f", attribute.second.mean, sqrt(attribute.second.m2 / attribute.second.numeric_count));
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t val_count = attribute.second.sample_values.size();
|
size_t val_count = attribute.second.sample_values.size();
|
||||||
if (val_count > max_tilestats_sample_values) {
|
if (val_count > max_tilestats_sample_values) {
|
||||||
|
|||||||
@@ -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 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);
|
auto layer = merged_layermaps->find(layername);
|
||||||
if (layer == merged_layermaps->end()) {
|
if (layer == merged_layermaps->end()) {
|
||||||
fprintf(stderr, "Can't find layer %s\n", layername.c_str());
|
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.
|
// or somewhere in between for more reasonably categorical values.
|
||||||
double interestingness = sqrt(xd * xd + yd * yd);
|
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) {
|
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user