use of com.airbnb.aerosolve.core.DebugScoreRecord in project aerosolve by airbnb.
the class FullRankLinearModel method debugScoreComponents.
@Override
public List<DebugScoreRecord> debugScoreComponents(FeatureVector combinedItem) {
Map<String, Map<String, Double>> flatFeatures = Util.flattenFeature(combinedItem);
List<DebugScoreRecord> scoreRecordsList = new ArrayList<>();
int dim = labelDictionary.size();
for (Map.Entry<String, Map<String, Double>> entry : flatFeatures.entrySet()) {
String familyKey = entry.getKey();
Map<String, FloatVector> family = weightVector.get(familyKey);
if (family != null) {
for (Map.Entry<String, Double> feature : entry.getValue().entrySet()) {
String featureKey = feature.getKey();
FloatVector featureWeights = family.get(featureKey);
float val = feature.getValue().floatValue();
if (featureWeights != null) {
for (int i = 0; i < dim; i++) {
DebugScoreRecord record = new DebugScoreRecord();
record.setFeatureFamily(familyKey);
record.setFeatureName(featureKey);
record.setFeatureValue(val);
record.setFeatureWeight(featureWeights.get(i));
record.setLabel(labelDictionary.get(i).label);
scoreRecordsList.add(record);
}
}
}
}
}
return scoreRecordsList;
}
use of com.airbnb.aerosolve.core.DebugScoreRecord in project aerosolve by airbnb.
the class SplineModel method debugScoreComponents.
@Override
public List<DebugScoreRecord> debugScoreComponents(FeatureVector combinedItem) {
Map<String, Map<String, Double>> flatFeatures = Util.flattenFeature(combinedItem);
List<DebugScoreRecord> scoreRecordsList = new ArrayList<>();
for (Map.Entry<String, Map<String, Double>> featureFamily : flatFeatures.entrySet()) {
Map<String, WeightSpline> familyWeightMap = weightSpline.get(featureFamily.getKey());
if (familyWeightMap == null)
continue;
for (Map.Entry<String, Double> feature : featureFamily.getValue().entrySet()) {
WeightSpline ws = familyWeightMap.get(feature.getKey());
if (ws == null)
continue;
float val = feature.getValue().floatValue();
float weight = ws.spline.evaluate(val);
DebugScoreRecord record = new DebugScoreRecord();
record.setFeatureFamily(featureFamily.getKey());
record.setFeatureName(feature.getKey());
record.setFeatureValue(val);
record.setFeatureWeight(weight);
scoreRecordsList.add(record);
}
}
return scoreRecordsList;
}
use of com.airbnb.aerosolve.core.DebugScoreRecord in project aerosolve by airbnb.
the class AdditiveModel method debugScoreComponents.
@Override
public List<DebugScoreRecord> debugScoreComponents(FeatureVector combinedItem) {
Map<String, Map<String, Double>> flatFeatures = Util.flattenFeature(combinedItem);
List<DebugScoreRecord> scoreRecordsList = new ArrayList<>();
for (Map.Entry<String, Map<String, Double>> featureFamily : flatFeatures.entrySet()) {
Map<String, Function> familyWeightMap = weights.get(featureFamily.getKey());
if (familyWeightMap == null)
continue;
for (Map.Entry<String, Double> feature : featureFamily.getValue().entrySet()) {
Function func = familyWeightMap.get(feature.getKey());
if (func == null)
continue;
float val = feature.getValue().floatValue();
float weight = func.evaluate(val);
DebugScoreRecord record = new DebugScoreRecord();
record.setFeatureFamily(featureFamily.getKey());
record.setFeatureName(feature.getKey());
record.setFeatureValue(val);
record.setFeatureWeight(weight);
scoreRecordsList.add(record);
}
}
Map<String, List<Double>> denseFeatures = combinedItem.getDenseFeatures();
if (denseFeatures != null) {
Map<String, Function> denseWeights = getOrCreateDenseWeights();
for (Map.Entry<String, List<Double>> feature : denseFeatures.entrySet()) {
String featureName = feature.getKey();
Function fun = denseWeights.get(featureName);
float[] val = toFloat(feature.getValue());
float weight = fun.evaluate(val);
DebugScoreRecord record = new DebugScoreRecord();
record.setFeatureFamily(DENSE_FAMILY);
record.setFeatureName(feature.getKey());
record.setDenseFeatureValue(feature.getValue());
record.setFeatureWeight(weight);
scoreRecordsList.add(record);
}
}
return scoreRecordsList;
}
use of com.airbnb.aerosolve.core.DebugScoreRecord in project aerosolve by airbnb.
the class BoostedStumpsModel method debugScoreComponents.
@Override
public List<DebugScoreRecord> debugScoreComponents(FeatureVector combinedItem) {
List<DebugScoreRecord> scoreRecordsList = new ArrayList<>();
Map<String, Map<String, Double>> floatFeatures = Util.flattenFeature(combinedItem);
for (ModelRecord stump : stumps) {
boolean response = getStumpResponse(stump, floatFeatures);
if (response) {
DebugScoreRecord record = new DebugScoreRecord();
record.setFeatureFamily(stump.featureFamily);
record.setFeatureName(stump.featureName);
record.setFeatureValue(floatFeatures.get(stump.featureFamily).get(stump.featureName));
record.setFeatureWeight(stump.featureWeight);
scoreRecordsList.add(record);
}
}
return scoreRecordsList;
}
use of com.airbnb.aerosolve.core.DebugScoreRecord in project aerosolve by airbnb.
the class LinearModel method debugScoreComponents.
@Override
public List<DebugScoreRecord> debugScoreComponents(FeatureVector combinedItem) {
// linear model takes only string features
Map<String, Set<String>> stringFeatures = combinedItem.getStringFeatures();
List<DebugScoreRecord> scoreRecordsList = new ArrayList<>();
if (stringFeatures == null || weights == null) {
return scoreRecordsList;
}
for (Entry<String, Set<String>> entry : stringFeatures.entrySet()) {
String family = entry.getKey();
Map<String, Float> inner = weights.get(family);
if (inner == null)
continue;
for (String value : entry.getValue()) {
DebugScoreRecord record = new DebugScoreRecord();
Float weight = inner.get(value);
if (weight != null) {
record.setFeatureFamily(family);
record.setFeatureName(value);
// 1.0 if the string feature exists, 0.0 otherwise
record.setFeatureValue(1.0);
record.setFeatureWeight(weight);
scoreRecordsList.add(record);
}
}
}
return scoreRecordsList;
}
Aggregations