c4emmmm commented on a change in pull request #8402: [FLINK-12473][ml] Add the 
interface of ML pipeline and ML lib
URL: https://github.com/apache/flink/pull/8402#discussion_r285683552
 
 

 ##########
 File path: 
flink-ml/flink-ml-api/src/main/java/org/apache/flink/ml/api/core/PipelineStage.java
 ##########
 @@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+package org.apache.flink.ml.api.core;
+
+import org.apache.flink.ml.api.misc.param.ParamInfo;
+import org.apache.flink.ml.api.misc.param.WithParams;
+import org.apache.flink.ml.api.misc.persist.Persistable;
+import org.apache.flink.ml.util.param.ExtractParamInfosUtil;
+import org.apache.flink.ml.util.persist.MLStageFactory;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Base class for a stage in a pipeline. The interface is only a concept, and 
does not have any
+ * actual functionality. Its subclasses must be either Estimator or 
Transformer. No other classes
+ * should inherit this interface directly.
+ *
+ * <p>Each pipeline stage is with parameters and meanwhile persistable.
+ *
+ * @param <T> The class type of the PipelineStage implementation itself, used 
by {@link
+ *            org.apache.flink.ml.api.misc.param.WithParams}
+ * @see WithParams
+ */
+interface PipelineStage<T extends PipelineStage<T>> extends WithParams<T>, 
Serializable,
+               Persistable {
+
+       default String toJson() {
 
 Review comment:
   @Rongrong @ex00 @blublinsky
   Thank you all for so much concern.
   
   I think most of your questions can be concluded as three points:
   1.Why use JSON rather than standard model languages like PMML? What if users 
want to use other format?
   2.How to serve a model?
   
   In fact the Persistable is designed to be used inside FlinkML only. It's not 
only the storage format but also a part of user interface, like SQL. We tried 
to design a SQL-like language to describe pipeline stages, but discarded since 
it's requiring users learn new things, which may be a disadvantage at the 
beginning of FlinkML. Though the json may be hard to write from zero, it is 
friendly enough to read and edit. We tried to support these separately but 
found that if the representation is defined reversible, it can meet both 
requirements.
   
   It's also planned to support standard model languages. Let's take PMML as 
the example. Since it is not reversible once a model is converted to PMML, and 
may be hard to describe all kinds of pipeline stages including pipelines, we 
didn't choose it as the unified storage format, but to provide a PMMLExportable 
interface. Models can implement it then users could convert their trained model 
to a PMML-format string or file.
   As for serving, it's supposed that Model.transform() does exactly what 
serving does. This means a user can easily serve their model trained by 
FlinkML, just save the model json then use it in his serving job. It's also 
possible to use the trained model outside Flink if the model implements 
PMMLExportable. We can also provide PMMLPredictor(extends Transformer) to serve 
an external PMML model. I also tried implement FLIP-23 proposed by blublinsky 
on top of this API. I put metadata of the updating model queue(like kafka) in 
the params then acquire the source in Model.transform(). Though the 
implementation is quite complex, it's universal and easy to use for users. We 
can do more to integrate FLIP-39 and FLIP-23 and provide better experience for 
users.
   
   This is what we thought about, and I hope it solve your problems. I would 
appreciate you letting me know if you have any question or think there's a 
mistake.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to