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 7F912200C39 for ; Thu, 16 Mar 2017 08:10:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 7E3B0160B7A; Thu, 16 Mar 2017 07:10:46 +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 CB17E160B78 for ; Thu, 16 Mar 2017 08:10:45 +0100 (CET) Received: (qmail 39370 invoked by uid 500); 16 Mar 2017 07:10:45 -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 39360 invoked by uid 99); 16 Mar 2017 07:10:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Mar 2017 07:10:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 8B26218F151 for ; Thu, 16 Mar 2017 07:10:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.651 X-Spam-Level: X-Spam-Status: No, score=0.651 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id p9N0E3-dnQn1 for ; Thu, 16 Mar 2017 07:10:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 31BEC5FB79 for ; Thu, 16 Mar 2017 07:10:43 +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 45847E0538 for ; Thu, 16 Mar 2017 07:10:42 +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 97513254B7 for ; Thu, 16 Mar 2017 07:10:41 +0000 (UTC) Date: Thu, 16 Mar 2017 07:10:41 +0000 (UTC) From: "Nick Pentreath (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SPARK-19962) add DictVectorizor for DataFrame MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 16 Mar 2017 07:10:46 -0000 [ https://issues.apache.org/jira/browse/SPARK-19962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15927601#comment-15927601 ] Nick Pentreath commented on SPARK-19962: ---------------------------------------- You may also want to take a look at https://issues.apache.org/jira/browse/SPARK-13969. I plan to work on the {{FeatureHasher}} (will be for Spark 2.3 now). I do think a {{DictVectorizer}} would be useful and is conceptually the same as my hasher but maintaining an exact feature mapping. > add DictVectorizor for DataFrame > -------------------------------- > > Key: SPARK-19962 > URL: https://issues.apache.org/jira/browse/SPARK-19962 > Project: Spark > Issue Type: Wish > Components: ML > Affects Versions: 2.1.0 > Reporter: yu peng > Labels: features > > it's really useful to have something like sklearn.feature_extraction.DictVectorizor > Since out features lives in json/data frame like format and classifier/regressors only take vector input. so there is a gap between them. > something like > ``` > df = sqlCtx.createDataFrame([Row(age=1, gender='male', country='cn', hobbies=['sing', 'dance']),Row(age=3, gender='female', country='us', hobbies=['sing']), ]) > df.show() > |age|gender|country|hobbies| > |1|male|cn|[sing, dance]| > |3|female|us|[sing]| > import DictVectorizor > vec = DictVectorizor() > matrix = vec.fit_transform(df) > matrix.show() > |features| > |[1, 0, 1, 0, 1, 1, 1]| > |[3, 1, 0, 1, 0, 1, 1]| > vec.show() > |feature_name| feature_dimension| > |age|0| > |gender=female|1| > |gender=male|2| > |country=us|3| > |country=cn|4| > |hobbies=sing|5| > |hobbies=dance|6| > ``` -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org