zhipeng93 commented on code in PR #151:
URL: https://github.com/apache/flink-ml/pull/151#discussion_r962460009


##########
docs/content/docs/operators/feature/elementwiseproduct.md:
##########
@@ -0,0 +1,157 @@
+---
+title: "Elementwise Product"
+weight: 1
+type: docs
+aliases:
+- /operators/feature/elementwiseproduct.html
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF 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.
+-->
+
+## Elementwise Product
+
+Elementwise Product multiplies each input vector with a given scaling vector 
using 
+Hadamard product. If the size of the input vector does not equal the size of 
the 
+scaling vector, the transformer will throw an IllegalArgumentException.
+
+### Input Columns
+
+| Param name | Type   | Default   | Description           |
+|:-----------|:-------|:----------|:----------------------|
+| inputCol   | Vector | `"input"` | features to be scaled |

Review Comment:
   nit: `features to be scaled` -> `Features to be scaled`
   
   same for the output features.



##########
docs/content/docs/operators/feature/elementwiseproduct.md:
##########
@@ -0,0 +1,157 @@
+---
+title: "Elementwise Product"
+weight: 1
+type: docs
+aliases:
+- /operators/feature/elementwiseproduct.html
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF 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.
+-->
+
+## Elementwise Product
+
+Elementwise Product multiplies each input vector with a given scaling vector 
using 
+Hadamard product. If the size of the input vector does not equal the size of 
the 
+scaling vector, the transformer will throw an IllegalArgumentException.
+
+### Input Columns
+
+| Param name | Type   | Default   | Description           |
+|:-----------|:-------|:----------|:----------------------|
+| inputCol   | Vector | `"input"` | features to be scaled |
+
+### Output Columns
+
+| Param name | Type   | Default    | Description     |
+|:-----------|:-------|:-----------|:----------------|
+| outputCol  | Vector | `"output"` | scaled features |
+
+### Parameters
+
+| Key        | Default    | Type   | Required | Description         |
+|------------|------------|--------|----------|---------------------|
+| inputCol   | `"input"`  | String | no       | Input column name.  |
+| outputCol  | `"output"` | String | no       | Output column name. |
+| scalingVec | `null`     | String | yes      | The scaling vector. |
+### Examples
+
+{{< tabs examples >}}
+
+{{< tab "Java">}}
+
+```java
+import org.apache.flink.ml.feature.elementwiseproduct.ElementwiseProduct;
+import org.apache.flink.ml.linalg.Vector;
+import org.apache.flink.ml.linalg.Vectors;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CloseableIterator;
+
+/**
+ * Simple program that creates a ElementwiseProduct instance and uses it for 
feature engineering.
+ */
+public class ElementwiseProductExample {
+    public static void main(String[] args) {
+        StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+        StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
+
+        // Generates input data.
+        DataStream<Row> inputStream =
+                env.fromElements(
+                        Row.of(0, Vectors.dense(1.1, 3.2)), Row.of(1, 
Vectors.dense(2.1, 3.1)));
+
+        Table inputTable = tEnv.fromDataStream(inputStream).as("id", "vec");
+
+        // Creates an ElementwiseProduct object and initializes its parameters.
+        ElementwiseProduct elementwiseProduct =
+                new ElementwiseProduct()
+                        .setInputCol("vec")
+                        .setOutputCol("outputVec")
+                        .setScalingVec(Vectors.dense(1.1, 1.1));
+
+        // Transforms input data.
+        Table outputTable = elementwiseProduct.transform(inputTable)[0];
+
+        // Extracts and displays the results.
+        for (CloseableIterator<Row> it = outputTable.execute().collect(); 
it.hasNext(); ) {
+            Row row = it.next();
+            Vector inputValue = (Vector) 
row.getField(elementwiseProduct.getInputCol());
+            Vector outputValue = (Vector) 
row.getField(elementwiseProduct.getOutputCol());
+            System.out.printf("Input Value: %s \tOutput Value: %s\n", 
inputValue, outputValue);
+        }
+    }
+}
+
+```
+
+{{< /tab>}}
+
+{{< tab "Python">}}
+
+```python
+# Simple program that creates a ElementwiseProduct instance and uses it for 
feature

Review Comment:
   nit: a -> an



##########
docs/content/docs/operators/feature/interaction.md:
##########
@@ -0,0 +1,169 @@
+---
+title: "Interaction"
+weight: 1
+type: docs
+aliases:
+- /operators/feature/interaction.html
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF 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.
+-->
+
+## Interaction
+
+Interaction takes vector or numerical columns, and generates a single vector 
column that contains
+the product of all combinations of one value from each input column.
+
+For example, when the input feature values are Double(2) and Vector(3, 4), the 
output would be 
+Vector(6, 8). When the input feature values are Vector(1, 2) and Vector(3, 4), 
the output would
+be Vector(3, 4, 6, 8). If you change the position of these two input Vectors, 
the output would 
+be Vector(3, 6, 4, 8).
+
+### Input Columns
+
+| Param name | Type   | Default | Description               |
+|:-----------|:-------|:--------|:--------------------------|
+| inputCols  | Vector | `null`  | Columns to be interacted. |
+
+### Output Columns
+
+| Param name | Type   | Default    | Description    |
+|:-----------|:-------|:-----------|:---------------|
+| outputCol  | Vector | `"output"` | Result vector. |

Review Comment:
   Should we make the description for the output vector consistent? e.g., 
"Interacted vector"?
   
   Same for other output vectors.



##########
docs/content/docs/operators/feature/maxabsscaler.md:
##########
@@ -0,0 +1,180 @@
+---
+title: "Max Abs Scaler"
+weight: 1
+type: docs
+aliases:
+- /operators/feature/maxabsscaler.html
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF 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.
+-->
+
+## Max Abs Scaler
+
+Max Abs Scaler is an algorithm rescales feature values to the range [-1, 1] 
+by dividing through the largest maximum absolute value in each feature. 
+It does not shift/center the data and thus does not destroy any sparsity.
+
+### Input Columns
+
+| Param name | Type   | Default   | Description           |
+|:-----------|:-------|:----------|:----------------------|
+| inputCol   | Vector | `"input"` | features to be scaled |

Review Comment:
   nit: Let's capitialize the first letter of the description.



##########
docs/content/docs/operators/feature/interaction.md:
##########
@@ -0,0 +1,169 @@
+---
+title: "Interaction"
+weight: 1
+type: docs
+aliases:
+- /operators/feature/interaction.html
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF 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.
+-->
+
+## Interaction
+
+Interaction takes vector or numerical columns, and generates a single vector 
column that contains
+the product of all combinations of one value from each input column.
+
+For example, when the input feature values are Double(2) and Vector(3, 4), the 
output would be 
+Vector(6, 8). When the input feature values are Vector(1, 2) and Vector(3, 4), 
the output would
+be Vector(3, 4, 6, 8). If you change the position of these two input Vectors, 
the output would 
+be Vector(3, 6, 4, 8).
+
+### Input Columns
+
+| Param name | Type   | Default | Description               |
+|:-----------|:-------|:--------|:--------------------------|
+| inputCols  | Vector | `null`  | Columns to be interacted. |
+
+### Output Columns
+
+| Param name | Type   | Default    | Description    |
+|:-----------|:-------|:-----------|:---------------|
+| outputCol  | Vector | `"output"` | Result vector. |
+
+### Parameters
+
+| Key             | Default    | Type      | Required | Description            
    |
+|-----------------|------------|-----------|----------|----------------------------|
+| inputCols       | `null`     | String[]  | yes      | Input column names.    
    |
+| outputCol       | `"output"` | String    | No       | Output column name.    
    |
+
+### Examples
+
+{{< tabs examples >}}
+
+{{< tab "Java">}}
+
+```java
+import org.apache.flink.ml.feature.interaction.Interaction;
+import org.apache.flink.ml.linalg.Vector;
+import org.apache.flink.ml.linalg.Vectors;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CloseableIterator;
+
+import java.util.Arrays;
+
+/** Simple program that creates an Interaction instance and uses it for 
feature engineering. */
+public class InteractionExample {
+    public static void main(String[] args) {
+        StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+        StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
+
+        // Generates input data.
+        DataStream<Row> inputStream =
+                env.fromElements(
+                        Row.of(0, Vectors.dense(1.1, 3.2), Vectors.dense(2, 
3)),
+                        Row.of(1, Vectors.dense(2.1, 3.1), Vectors.dense(1, 
3)));
+
+        Table inputTable = tEnv.fromDataStream(inputStream).as("f0", "f1", 
"f2");
+
+        // Creates an Interaction object and initializes its parameters.
+        Interaction interaction =
+                new Interaction().setInputCols("f0", "f1", 
"f2").setOutputCol("outputVec");
+
+        // Transforms input data.
+        Table outputTable = interaction.transform(inputTable)[0];
+
+        // Extracts and displays the results.
+        for (CloseableIterator<Row> it = outputTable.execute().collect(); 
it.hasNext(); ) {
+            Row row = it.next();
+            Object[] inputValues = new 
Object[interaction.getInputCols().length];
+            for (int i = 0; i < inputValues.length; i++) {
+                inputValues[i] = row.getField(interaction.getInputCols()[i]);
+            }
+            Vector outputValue = (Vector) 
row.getField(interaction.getOutputCol());
+            System.out.printf(
+                    "Input Values: %s \tOutput Value: %s\n",
+                    Arrays.toString(inputValues), outputValue);
+        }
+    }
+}
+
+```
+
+{{< /tab>}}
+
+{{< tab "Python">}}
+
+```python
+# Simple program that creates a Interaction instance and uses it for feature

Review Comment:
   a -> an



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to