PMML Export

kumarbhaskar8
Level 1
PMML Export

Hi, 

 

I am looking for ways to automate the pmml export to Teradata Database table by creating a plugin. Is there a way I could see the pmml exporting python code and replicate that in python recipe to automate it?

0 Kudos
6 Replies
kumarbhaskar8
Level 1
Author

Can I convert the "dataiku.core.saved_model.Model" to "pmml"? If yes, please help me with that.

0 Kudos
arnaudde
Dataiker

Hello,
You can convert a dss saved model to pmml with the dss python api method get_scoring_pmml_stream.
Here is a code sample to do so from a notebook.
I hope it helps,
Arnaud

import dataiku

client = dataiku.api_client()
pmml_model_as_string = client.get_project('PROJECT_KEY').get_saved_model('SAVED_MODEL_ID').get_version_details('initial').get_scoring_pmml_stream().content

 

kumarbhaskar8
Level 1
Author

Thank you so much @arnaudde, that was an awesome solution!

is there a way to insert the extracted pmml into a database table with the existing database connection?

 

0 Kudos
arnaudde
Dataiker

The shape of the pmml models will vary significantly so I think it makes more sense to store the pmml files as xml files in a managed folder. 
Hope it helps,
Arnaud

0 Kudos
kumarbhaskar8
Level 1
Author

Hi,

I understand that but my main goal is to push the pmml to the database table directly without downloading and importing into database. In Teradata Database I can score the models within the database if I can push the pmml into a table. Anyway, help with this, how can I insert data/objects into database table from python recipe. 

I have attached a screenshot of how I am trying to insert it. Please give your input on this.

Thanks,

Kumar

0 Kudos
arnaudde
Dataiker

Hello,
Your format statement does not do anything:

sql_statement.format(table_name="...")

 You should use brackets, like explained here. 

0 Kudos