Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 38AC0200D16 for ; Tue, 26 Sep 2017 01:19:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 371F71609E9; Mon, 25 Sep 2017 23:19:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7AC071609BB for ; Tue, 26 Sep 2017 01:19:06 +0200 (CEST) Received: (qmail 53232 invoked by uid 500); 25 Sep 2017 23:19:05 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 53223 invoked by uid 99); 25 Sep 2017 23:19:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 25 Sep 2017 23:19:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 172861A3D34 for ; Mon, 25 Sep 2017 23:19:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id qHD3ClH3RRh1 for ; Mon, 25 Sep 2017 23:19:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 5CCA76129A for ; Mon, 25 Sep 2017 23:19:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 778F4E0F4C for ; Mon, 25 Sep 2017 23:19:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 82DA02428A for ; Mon, 25 Sep 2017 23:19:00 +0000 (UTC) Date: Mon, 25 Sep 2017 23:19:00 +0000 (UTC) From: "Bryan Cutler (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (SPARK-22034) CrossValidator's training and testing set with different set of labels, resulting in encoder transform error MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 25 Sep 2017 23:19:07 -0000 [ https://issues.apache.org/jira/browse/SPARK-22034?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16179938#comment-16179938 ] Bryan Cutler edited comment on SPARK-22034 at 9/25/17 11:18 PM: ---------------------------------------------------------------- You would normally fit the VectorIndexer on the entire dataset and then put the resulting transformer in the pipeline for cross validation. This is not a bug unless I'm mistaken. For example: https://github.com/apache/spark/blob/master/examples/src/main/scala/org/apache/spark/examples/ml/RandomForestClassifierExample.scala#L52 was (Author: bryanc): You would normally fit the VectorIndexer on the entire dataset and then put the resulting transformer in the pipeline for cross validation. This is not a bug unless I'm mistaken. > CrossValidator's training and testing set with different set of labels, resulting in encoder transform error > ------------------------------------------------------------------------------------------------------------ > > Key: SPARK-22034 > URL: https://issues.apache.org/jira/browse/SPARK-22034 > Project: Spark > Issue Type: Bug > Components: MLlib > Affects Versions: 2.2.0 > Environment: Ubuntu 16.04 > Scala 2.11 > Spark 2.2.0 > Reporter: AnChe Kuo > Original Estimate: 72h > Remaining Estimate: 72h > > Let's say we have a VectorIndexer with maxCategories set to 13, and training set has a column containing month label. > In CrossValidator, dataframe is split into training and testing set automatically. If could happen that training set happens to lack month 2 (could happen by chance, or happen quite frequently if we have unbalanced label). > When training set is being trained within the cross validator, the pipeline is fitted with the training set only, resulting in a partial key map in VectorIndexer. When this pipeline is used to transform the predict set, VectorIndexer will throw a "key not found" error. > Making CrossValidator also an estimator thus can be connected to a whole pipeline is a cool idea, but bug like this occurs, and is not expected. > The solution, I am guessing, would be to check each stage in the pipeline, and when we see encoder type stage, we fit the stage model with the complete dataset. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org