forked from wso2/carbon-ml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
144 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
....core/src/main/java/org/wso2/carbon/ml/core/spark/summary/RecommendationModelSummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.wso2.carbon.ml.core.spark.summary; | ||
|
||
import org.apache.spark.rdd.RDD; | ||
import org.wso2.carbon.ml.commons.constants.MLConstants; | ||
import org.wso2.carbon.ml.commons.domain.ModelSummary; | ||
import scala.Tuple2; | ||
|
||
import java.io.Serializable; | ||
import java.util.Arrays; | ||
|
||
public class RecommendationModelSummary implements ModelSummary, Serializable { | ||
|
||
private static final long serialVersionUID = 5557613175001838756L; | ||
private String algorithm; | ||
private String[] features; | ||
private int rank; | ||
private RDD<Tuple2<Object, double[]>> userFeatures; | ||
private RDD<Tuple2<Object, double[]>> productFeatures; | ||
|
||
@Override | ||
public String getModelSummaryType() { | ||
return MLConstants.RECOMMENDATION_MODEL_SUMMARY; | ||
} | ||
|
||
public String getAlgorithm() { | ||
return algorithm; | ||
} | ||
|
||
public void setAlgorithm(String algorithm) { | ||
this.algorithm = algorithm; | ||
} | ||
|
||
public int getRank() { | ||
return rank; | ||
} | ||
|
||
public void setRank(int rank) { | ||
this.rank = rank; | ||
} | ||
|
||
public RDD<Tuple2<Object, double[]>> getUserFeatures() { | ||
return userFeatures; | ||
} | ||
|
||
public void setUserFeatures(RDD<Tuple2<Object, double[]>> userFeatures) { | ||
this.userFeatures = userFeatures; | ||
} | ||
|
||
public RDD<Tuple2<Object, double[]>> getProductFeatures() { | ||
return productFeatures; | ||
} | ||
|
||
public void setProductFeatures(RDD<Tuple2<Object, double[]>> productFeatures) { | ||
this.productFeatures = productFeatures; | ||
} | ||
|
||
/** | ||
* @param features Array of names of the features | ||
*/ | ||
public void setFeatures(String[] features) { | ||
if (features == null) { | ||
this.features = new String[0]; | ||
} else { | ||
this.features = Arrays.copyOf(features, features.length); | ||
} | ||
} | ||
|
||
@Override | ||
public String[] getFeatures() { | ||
return features; | ||
} | ||
} |