flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-2259) Support training Estimators using a (train, validation, test) split of the available data
Date Tue, 17 May 2016 11:47:13 GMT

    [ https://issues.apache.org/jira/browse/FLINK-2259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15286441#comment-15286441
] 

ASF GitHub Bot commented on FLINK-2259:
---------------------------------------

Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1898#discussion_r63507717
  
    --- Diff: flink-libraries/flink-ml/src/main/scala/org/apache/flink/ml/preprocessing/Splitter.scala
---
    @@ -0,0 +1,210 @@
    +/*
    + * 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.preprocessing
    +
    +import org.apache.flink.api.common.typeinfo.{TypeInformation, BasicTypeInfo}
    +import org.apache.flink.api.java.Utils
    +import org.apache.flink.api.scala._
    +import org.apache.flink.api.scala.DataSet
    +import org.apache.flink.api.scala.utils._
    +
    +
    +import org.apache.flink.ml.common.{FlinkMLTools, ParameterMap, WithParameters}
    +import org.apache.flink.util.Collector
    +import _root_.scala.reflect.ClassTag
    +
    +object Splitter {
    +
    +  case class TrainTestDataSet[T: TypeInformation : ClassTag](training: DataSet[T],
    +                                                             testing: DataSet[T])
    +
    +  case class TrainTestHoldoutDataSet[T: TypeInformation : ClassTag](training: DataSet[T],
    +                                                                    testing: DataSet[T],
    +                                                                    holdout: DataSet[T])
    +  // --------------------------------------------------------------------------------------------
    +  //  randomSplit
    +  // --------------------------------------------------------------------------------------------
    +  /**
    +   * Split a DataSet by the probability fraction of each element.
    +   *
    +   * @param input           DataSet to be split
    +   * @param fraction        Probability that each element is chosen, should be [0,1]
This fraction
    +   *                        refers to the first element in the resulting array.
    +   * @param precise         Sampling by default is random and can result in slightly
lop-sided
    +   *                        sample sets. When precise is true, equal sample set size
are forced,
    +   *                        however this is somewhat less efficient.
    +   * @param seed            Random number generator seed.
    +   * @return An array of two datasets
    +   */
    +
    +  def randomSplit[T: TypeInformation : ClassTag](
    +      input: DataSet[T],
    +      fraction: Double,
    +      precise: Boolean = false,
    +      seed: Long = Utils.RNG.nextLong())
    +    : Array[DataSet[T]] = {
    +    import org.apache.flink.api.scala._
    +
    +    val indexedInput: DataSet[(Long, T)] = input.zipWithUniqueId
    +
    +    if ((fraction >= 1) || (fraction <= 0)) {
    +      throw new IllegalArgumentException("sampling fraction outside of (0,1) bounds is
nonsensical")
    +    }
    +
    +    val leftSplit: DataSet[(Long, T)] = precise match {
    +      case false => indexedInput.sample(false, fraction, seed)
    +      case true => {
    +        val count = indexedInput.count()
    +        val numOfSamples = math.round(fraction * count).toInt
    +        indexedInput.sampleWithSize(false, numOfSamples, seed)
    +      }
    +    }
    +
    +    val rightSplit: DataSet[T] = indexedInput.leftOuterJoin[(Long, T)](leftSplit)
    --- End diff --
    
    before doing the `leftOuterJoin` we could strip the `leftSplit` from it's payload and
simply joining with the ids. That would reduce the network I/O.


> Support training Estimators using a (train, validation, test) split of the available
data
> -----------------------------------------------------------------------------------------
>
>                 Key: FLINK-2259
>                 URL: https://issues.apache.org/jira/browse/FLINK-2259
>             Project: Flink
>          Issue Type: New Feature
>          Components: Machine Learning Library
>            Reporter: Theodore Vasiloudis
>            Assignee: Trevor Grant
>            Priority: Minor
>              Labels: ML
>
> When there is an abundance of data available, a good way to train models is to split
the available data into 3 parts: Train, Validation and Test.
> We use the Train data to train the model, the Validation part is used to estimate the
test error and select hyperparameters, and the Test is used to evaluate the performance of
the model, and assess its generalization [1]
> This is a common approach when training Artificial Neural Networks, and a good strategy
to choose in data-rich environments. Therefore we should have some support of this data-analysis
process in our Estimators.
> [1] Friedman, Jerome, Trevor Hastie, and Robert Tibshirani. The elements of statistical
learning. Vol. 1. Springer, Berlin: Springer series in statistics, 2001.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message