|
@@ -8,6 +8,8 @@ import com.tzld.piaoquan.recommend.feature.domain.ad.base.*;
|
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.feature.VlogAdCtrLRFeatureExtractor;
|
|
|
import com.tzld.piaoquan.recommend.feature.model.sample.BaseFeature;
|
|
|
import com.tzld.piaoquan.recommend.feature.model.sample.FeatureGroup;
|
|
|
+import com.tzld.piaoquan.recommend.feature.model.sample.GroupedFeature;
|
|
|
+import com.tzld.piaoquan.recommend.feature.model.sample.LRSamples;
|
|
|
import examples.dataloader.AdSampleConstructor;
|
|
|
import org.apache.spark.SparkConf;
|
|
|
import org.apache.spark.aliyun.odps.OdpsOps;
|
|
@@ -77,13 +79,9 @@ public class SparkAdCTRSampleLoader {
|
|
|
VlogAdCtrLRFeatureExtractor bytesFeatureExtractor;
|
|
|
bytesFeatureExtractor = new VlogAdCtrLRFeatureExtractor();
|
|
|
|
|
|
- bytesFeatureExtractor.getUserFeatures(userBytesFeature);
|
|
|
- bytesFeatureExtractor.getItemFeature(adItemBytesFeature);
|
|
|
- bytesFeatureExtractor.getContextFeatures(adRequestContextBytesFeature);
|
|
|
- bytesFeatureExtractor.getCrossFeature(adItemBytesFeature, adRequestContextBytesFeature, userBytesFeature);
|
|
|
+ LRSamples lrSamples = bytesFeatureExtractor.single(userBytesFeature, adItemBytesFeature, adRequestContextBytesFeature);
|
|
|
|
|
|
- ListMultimap<FeatureGroup, BaseFeature> featureMap = bytesFeatureExtractor.getFeatures();
|
|
|
- return parseSamplesToString2(label, featureMap);
|
|
|
+ return parseSamplesToString2(label, lrSamples);
|
|
|
}
|
|
|
|
|
|
// 构建样本的字符串
|
|
@@ -100,16 +98,17 @@ public class SparkAdCTRSampleLoader {
|
|
|
|
|
|
|
|
|
// 构建样本的字符串
|
|
|
- public static String parseSamplesToString2(String label, ListMultimap<FeatureGroup, BaseFeature> featureMap) {
|
|
|
+ public static String parseSamplesToString2(String label, LRSamples lrSamples) {
|
|
|
ArrayList<String> featureList = new ArrayList<String>();
|
|
|
- List<FeatureGroup> keys = new ArrayList<>(featureMap.keySet());
|
|
|
-
|
|
|
- for (FeatureGroup group : keys) {
|
|
|
- List<BaseFeature> feaList = featureMap.get(group);
|
|
|
- for(BaseFeature baseFeature : feaList){
|
|
|
- Long featureIdentifier = baseFeature.getIdentifier();
|
|
|
- String feaName = baseFeature.getFea();
|
|
|
- featureList.add(String.valueOf(feaName) + ":1");
|
|
|
+ for (int i = 0; i < lrSamples.getFeaturesCount(); i++) {
|
|
|
+ GroupedFeature groupedFeature = lrSamples.getFeatures(i);
|
|
|
+ if (groupedFeature != null && groupedFeature.getFeaturesCount() != 0) {
|
|
|
+ for (int j = 0; j < groupedFeature.getFeaturesCount(); j++) {
|
|
|
+ BaseFeature baseFeature = groupedFeature.getFeatures(j);
|
|
|
+ if (baseFeature != null) {
|
|
|
+ featureList.add(baseFeature.getFea());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|