yunfengzhou-hub commented on code in PR #116:
URL: https://github.com/apache/flink-ml/pull/116#discussion_r905794591
##########
docs/content/docs/operators/classification/knn.md:
##########
@@ -175,15 +176,10 @@ predict_data = t_env.from_data_stream(
knn = KNN()
model = knn.fit(train_data)
output = model.transform(predict_data)[0]
-output.execute().print()
+print([result for result in
t_env.to_data_stream(output).execute_and_collect()])
# output
-#
+----+--------------------------------+--------------------------------+--------------------------------+
-# | op | features | label |
prediction |
-#
+----+--------------------------------+--------------------------------+--------------------------------+
-# | +I | [4.0, 4.1] | 5.0 |
5.0 |
-# | +I | [300.0, 42.0] | 2.0 |
2.0 |
-#
+----+--------------------------------+--------------------------------+--------------------------------+
+# [<Row(DenseVector([4.0, 4.1]), 5.0, 5.0)>, <Row(DenseVector([300.0, 42.0]),
2.0, 2.0)>]
Review Comment:
Would it be better if we reformat the output to improve its readability? For
example, the KMeans Java example would print the results as follows.
```java
for (CloseableIterator<Row> it = output.execute().collect(); it.hasNext(); )
{
Row row = it.next();
DenseVector vector = (DenseVector) row.getField(featuresCol);
int clusterId = (Integer) row.getField(predictionCol);
System.out.println("Vector: " + vector + "\tCluster ID: " + clusterId);
}
##########
docs/content/docs/operators/classification/logisticregression.md:
##########
@@ -148,23 +149,8 @@ logistic_regression =
LogisticRegression().set_weight_col('weight')
model = logistic_regression.fit(binomial_data_table)
output = model.transform(binomial_data_table)[0]
-output.execute().print()
-
-# output
-#
+----+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+
-# | op | features | label |
weight | prediction |
rawPrediction |
-#
+----+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+
-# | +I | [1.0, 2.0, 3.0, 4.0] | 0.0 |
1.0 | 0.0 |
[0.9731815427669942, 0.0268... |
-# | +I | [5.0, 2.0, 3.0, 4.0] | 0.0 |
5.0 | 0.0 |
[0.8158018538556746, 0.1841... |
-# | +I | [14.0, 2.0, 3.0, 4.0] | 1.0 |
4.0 | 1.0 |
[0.03753179912156068, 0.962... |
-# | +I | [3.0, 2.0, 3.0, 4.0] | 0.0 |
3.0 | 0.0 |
[0.926886620226911, 0.07311... |
-# | +I | [12.0, 2.0, 3.0, 4.0] | 1.0 |
2.0 | 1.0 |
[0.10041228069167174, 0.899... |
-# | +I | [4.0, 2.0, 3.0, 4.0] | 0.0 |
4.0 | 0.0 |
[0.8822580948141717, 0.1177... |
-# | +I | [13.0, 2.0, 3.0, 4.0] | 1.0 |
3.0 | 1.0 |
[0.061891528893188164, 0.93... |
-# | +I | [2.0, 2.0, 3.0, 4.0] | 0.0 |
2.0 | 0.0 |
[0.9554533965544176, 0.0445... |
-# | +I | [11.0, 2.0, 3.0, 4.0] | 1.0 |
1.0 | 1.0 |
[0.15884837044317868, 0.841... |
-# | +I | [15.0, 2.0, 3.0, 4.0] | 1.0 |
5.0 | 1.0 |
[0.022529496926532833, 0.97... |
-#
+----+--------------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------+
+print([result for result in
t_env.to_data_stream(output).execute_and_collect()])
+
Review Comment:
nit: there might also be an `#output` section here.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]