From dev-return-2509-archive-asf-public=cust-asf.ponee.io@systemml.apache.org Mon Jul 9 09:11:07 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 6B93A18062A for ; Mon, 9 Jul 2018 09:11:06 +0200 (CEST) Received: (qmail 26455 invoked by uid 500); 9 Jul 2018 07:11:05 -0000 Mailing-List: contact dev-help@systemml.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@systemml.apache.org Delivered-To: mailing list dev@systemml.apache.org Received: (qmail 26443 invoked by uid 99); 9 Jul 2018 07:11:04 -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; Mon, 09 Jul 2018 07:11:04 +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 33B661801AF for ; Mon, 9 Jul 2018 07:11:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.011 X-Spam-Level: X-Spam-Status: No, score=-0.011 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_PASS=-0.001, T_DKIMWL_WL_MED=-0.01] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=sbb.onmicrosoft.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id an8KJl8oenYQ for ; Mon, 9 Jul 2018 07:11:01 +0000 (UTC) Received: from sbbmail1.sbb.ch (sbbmail1.sbb.ch [194.150.245.161]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 2304B5F1D3 for ; Mon, 9 Jul 2018 07:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sbb.onmicrosoft.com; s=selector1-sbb-ch; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Dw6gfZCoEVhPpDaFDsBrirPnHYAiuDUfCeIdQD/X/BY=; b=jm3gW6A5H/B/CT8/oJ9yQ+E/lOmSxen9l6m4o/g+heCQQjF1bdEs1nxRzhZbvkPd8aKfJt9/Mflb2vq2zrwOcuzGIJ0KKLYpFlIFDgVF5JWNOYFZvuaEVnW6hxzjcsIIzV6YKy4qDcCPIZVRHowxbSffbEZrAFX2+JMA2KYM5cI= From: "Baeriswyl Kuno (IT-SWE-CC1-JV6)" To: "dev@systemml.apache.org" Subject: RE: which() Function in SystemML Thread-Topic: which() Function in SystemML Thread-Index: AdQUW9nrOBh9oQf/Sz+G3zIj0o8OHAAKXBeAAEB5a4AAcvrzcA== Date: Mon, 9 Jul 2018 07:10:51 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=kuno.baeriswyl@sbb.ch; x-originating-ip: [195.65.154.62] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR01MB3775;7:ZvZroTZA+Pfufpc9uOSMawhlPsYCNhYOoYtbOGq9Gf41spIdsWLqelmD6/cfteye6tzdC4ozsDzoIh8fqb7TFSiLOS2VROTzwE+ZfefoWxDcfB842HE2kzoWfU/7uggF2AK41AkYV/bTqKDmUJ28ZE9Lw/kjumxzCdmLKOBIUSzCKF4MsKdNPeMgWdwCSzsRmDIgKw7ZHastCEf7DHrOacGFucFNvNTf6f3Tlwln3y+winw0YW3u4n0AfXjknGNJ x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 9ccad298-f0cf-45b1-7058-08d5e56b1a94 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(2017052603328)(7153060)(7193020);SRVR:VI1PR01MB3775; x-ms-traffictypediagnostic: VI1PR01MB3775: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(166708455590820)(788757137089)(274839183919467)(104084551191319); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231311)(944501410)(52105095)(10201501046)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016);SRVR:VI1PR01MB3775;BCL:0;PCL:0;RULEID:;SRVR:VI1PR01MB3775; x-forefront-prvs: 07283408BE x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(136003)(366004)(376002)(346002)(396003)(40764003)(129404003)(252514010)(199004)(13464003)(189003)(6436002)(316002)(55016002)(3846002)(966005)(7696005)(6116002)(66066001)(53546011)(478600001)(6246003)(16799955002)(102836004)(53936002)(229853002)(15188155005)(33656002)(99286004)(6306002)(2906002)(26005)(9686003)(76176011)(5640700003)(6506007)(74316002)(25786009)(14454004)(305945005)(186003)(2351001)(256004)(97736004)(68736007)(7736002)(14444005)(8936002)(1730700003)(81166006)(8676002)(81156014)(2900100001)(1720100001)(74482002)(476003)(5660300001)(6916009)(86362001)(2501003)(446003)(5250100002)(105586002)(106356001)(11346002)(486006);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR01MB3775;H:VI1PR01MB4192.eurprd01.prod.exchangelabs.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: sbb.ch does not designate permitted sender hosts) x-microsoft-antispam-message-info: zVNDY11CdIh+SB3tkrXiaiIFAHfOtDnehjNkrxEjT9glVNYadIhfDKbb8gKIHX1FXysunQOCTg/AsNR094+XWcPJQo8oBXqnks53zUl27uWKUQIu/TaZehI98pNOuyj4Gt2j8wpblo/MH5sWe4bqkjL4upA2oZk4Vz4hlGXnufthnjOMmSZ/qenKL0vPDfk23i8Rpf1y1NJoFhTepev7rNkCRTTRWkbdXgYEzVlm1uIjt3/ion9uF+MR2PTXI4Uj4LwJdLXXONj0iZoVtInxZ13HQ6yp3yxPWp6IdJNUo21LW2WenHlUuPukaNKfdOh/FendiHw54/mFrCMfqifKZ5hWcVCkPYKmYw87RsP3YGc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 9ccad298-f0cf-45b1-7058-08d5e56b1a94 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Jul 2018 07:10:51.1339 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 2cda5d11-f0ac-46b3-967d-af1b2e1bd01a X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR01MB3775 Hallo Berthold, Niketan, Thanks for your helpful answers. Finally, I've done following implementations: #### which with for loop A =3D matrix("1 3 5 2 4", rows=3D5, cols=3D1) which =3D function (matrix[double] A) return (matrix[double] R) { R =3D matrix(0, 0, 1); n =3D nrow(A) for( i in 1:n ) { if(as.scalar(A[i,1]) > 0) { R =3D rbind(R, matrix(as.integer(i), 1, 1)) } } } A2 =3D A>2 R =3D which(A2) #### which with replace (Thanks to Niketan, I've understood the removeEmpty= syntax ,finally ) A =3D matrix("1 3 5 2 4", rows=3D5, cols=3D1) which =3D function (matrix[double] A) return (matrix[double] R) { R =3D removeEmpty(target=3DA*seq(1, nrow(A)), margin=3D"rows")=20 } C =3D A>2 R =3D which(C) #### is.na=20 A =3D matrix("1 3 5 0 4", rows=3D5, cols=3D1) A[3,1] =3D A[3,1]/0 is_na =3D function (matrix[double] A) return (matrix[double] R) { R =3D A =3D=3D 1/0 } R =3D is_na(A) Kuno -----Original Message----- From: Berthold Reinwald [mailto:reinwald@us.ibm.com]=20 Sent: Samstag, 7. Juli 2018 02:12 To: dev@systemml.apache.org Subject: Re: which() Function in SystemML You may also look at example 2 "Replace NaN with mode" in our "DML Tips and= Tricks" examples notebook. Will add a which() example shortly. https://github.com/apache/systemml/raw/master/samples/jupyter-notebooks/DML= %20Tips%20and%20Tricks%20(aka%20Fun%20With%20DML).ipynb Regards, Berthold Reinwald IBM Almaden Research Center office: (408) 927 2208; T/L: 457 2208 e-mail: reinwald@us.ibm.com From: "Niketan Pansare" To: dev@systemml.apache.org Date: 07/05/2018 10:26 AM Subject: Re: which() Function in SystemML Hi Kuno, Thanks for trying out SystemML. One way to implement your logic in SystemML= is as follows: X =3D matrix("1 4 -99 2 5 -99", rows=3D6, cols=3D1) Y =3D removeEmpty(targe= t=3D(X > 2)*seq(1, nrow(X)), margin=3D"rows") print("\nIndexes:\n" + toStri= ng(Y)) For handling NAs, you can replace NAs by certain value (in this case -99 or= one of the builtin constants, i.e. Inf or NaN ... see https://github.com/a= pache/systemml/blob/master/src/test/scripts/org/apache/sysml/api/mlcontext/= builtin-constants-test.dml ) using the "na.strings" parameter of the transform builtin function ( http= ://apache.github.io/systemml/dml-language-reference.html#transforming-frame= s ).=20 Hope this helps. Regards, Niketan Pansare IBM Almaden Research Center E-mail: npansar At us.ibm.com http://researcher.watson.ibm.com/researcher/view.php?person=3Dus-npansar "Baeriswyl Kuno (IT-SWE-CC1-JV6)" ---07/05/2018 05:29:53 AM---Hello, I'm a = developer want to use SystemMl for running R-Code from our business people = on a Spark c From: "Baeriswyl Kuno (IT-SWE-CC1-JV6)" To: "dev@systemml.apache.org" Date: 07/05/2018 05:29 AM Subject: which() Function in SystemML Hello, I'm a developer want to use SystemMl for running R-Code from our business p= eople on a Spark cluster. I've studied http://apache.github.io/systemml/dml-language-reference , howe= ver, haven't found a implementation of the R function "which" or any altern= ative functionality. Has anyone an idea how I could # Given v =3D c(1,4,NA,2, 5, NA) # Expect indexes where value meets condition =3D int[] 2 5 v2 =3D which(v>2) # Expect indexes where is.na returns TRUE =3D int[] 3 6 v3 =3D which(is.na(v)) I've already considered the functions replace() and removeEmpty(), but they= don't exactly meets my needs. Thanks a lot in advance Kuno