Skip to content

IBMPredictiveAnalytics/Python_Extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python_Extension

This extension try provider a common node to execute python script. Screenshot Screenshot1


Requirements

  • IBM SPSS Modeler v18

More information here: IBM Predictive Extensions


Installation instructions

Install extension from Extension Hub

  1. Open Extension Hub in Modeler Client by: "Extensions" -> "Extension Hub"
  2. Select "Spark ML Feature TF-IDF"
  3. Click "OK" to start auto installation

Install extension manually

  1. Open extension repository organization Github IBM Predictive Analytics
  2. Search and open repository, download corresponding *.mpe file.
  3. Start installation by: "Extensions" -> "Install Local Extension Bundle"
  4. Select *.mpe file and install it.

Python Scripts Example

Use sys.argv to share variable

Get inputDataframe and inputSchema from sys.argv

Save outputDataframe and outputSchema to sys.argv after data transform

Example Code:

from pyspark.sql.functions import lit
from pyspark.sql.types import StructType, StructField, DoubleType
import sys


data = sys.argv['inputDataframe']
schema = sys.argv['inputSchema']

if sys.argv['schemaOnly']:
    sys.argv['outputSchema'] = StructType(data.schema.fields + 
                    [StructField("newConstant", DoubleType(), False) ])
else:
    sys.argv['outputDataframe'] = data.withColumn('new', lit(1.0))

License

Apache 2.0


Next Step

In next release, python model node will provider that able to produce a nugget node.


Contributors

About

python common extension node

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages