public class Swing extends Object implements AlgoOperator<Swing>, SwingParams<Swing>
Swing is an item recall algorithm. The topology of user-item graph usually can be described as user-item-user or item-user-item, which are like 'swing'. For example, if both user u and user v have purchased the same commodity i, they will form a relationship diagram similar to a swing. If u and v have purchased commodity j in addition to i, it is supposed i and j are similar. The similarity between items in Swing is defined as
$$ w_{(i,j)}=\sum_{u\in U_i\cap U_j}\sum_{v\in U_i\cap U_j}{\frac{1}{{(|I_u|+\alpha_1)}^\beta}}*{\frac{1}{{(|I_v|+\alpha_1)}^\beta}}*{\frac{1}{\alpha_2+|I_u\cap I_v|}} $$
Note that alpha1 and alpha2 could be zero here. If one of $$|I_u|, |I_v| and |I_u\cap I_v|$$ is zero, then the similarity of i and j is zero.
See "Large Scale Product Graph Construction for Recommendation in E-commerce" by Xiaoyong Yang, Yadong Zhu and Yi Zhang.
ALPHA1, ALPHA2, BETA, ITEM_COL, K, MAX_USER_BEHAVIOR, MAX_USER_NUM_PER_ITEM, MIN_USER_BEHAVIOR, USER_COL
OUTPUT_COL
Constructor and Description |
---|
Swing() |
Modifier and Type | Method and Description |
---|---|
Map<Param<?>,Object> |
getParamMap()
Returns a map which should contain value for every parameter that meets one of the following
conditions.
|
static Swing |
load(org.apache.flink.table.api.bridge.java.StreamTableEnvironment tEnv,
String path) |
void |
save(String path)
Saves the metadata and bounded data of this stage to the given path.
|
org.apache.flink.table.api.Table[] |
transform(org.apache.flink.table.api.Table... inputs)
Applies the AlgoOperator on the given input tables and returns the result tables.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAlpha1, getAlpha2, getBeta, getItemCol, getK, getMaxUserBehavior, getMaxUserNumPerItem, getMinUserBehavior, getUserCol, setAlpha1, setAlpha2, setBeta, setItemCol, setK, setMaxUserBehavior, setMaxUserNumPerItem, setMinUserBehavior, setUserCol
getOutputCol, setOutputCol
get, getParam, set
public org.apache.flink.table.api.Table[] transform(org.apache.flink.table.api.Table... inputs)
AlgoOperator
transform
in interface AlgoOperator<Swing>
inputs
- a list of tablespublic Map<Param<?>,Object> getParamMap()
WithParams
1) set(...) has been called to set value for this parameter.
2) The parameter is a public final field of this WithParams instance. This includes fields inherited from its interfaces and super-classes.
The subclass which implements this interface could meet this requirement by returning a
member field of the given map type, after having initialized this member field using the
ParamUtils.initializeMapWithDefaultValues(Map, WithParams)
method.
getParamMap
in interface WithParams<Swing>
public void save(String path) throws IOException
Stage
save
in interface Stage<Swing>
IOException
public static Swing load(org.apache.flink.table.api.bridge.java.StreamTableEnvironment tEnv, String path) throws IOException
IOException
Copyright © 2019–2023 The Apache Software Foundation. All rights reserved.