![]() |
How to use a pmml model in Python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: How to use a pmml model in Python (/thread-4278.html) |
How to use a pmml model in Python - FlamingGuava - Aug-04-2017 Hey, I have a small neural network model, 25 neurons, that I trained recently, that I want to use to scan executable files with, to determine if they're safe or not. I transferred the model from R to pmml, and I already made a small code to scan executable files and extract system calls with, which I then turn into 0/1 vectors. My question is, how do I input these vectors into the pmml model, and how do I get them to give me a simple yes/no result? RE: How to use a pmml model in Python - radioactive9 - Aug-05-2017 Hello Did you save the learning in .json,.h5, .npy ? Sorry no clue exactly how it looks - and I have not worked on pmml models. But below is what might help you or point you to correct direction. from keras.models import model_from_json from sklearn.preprocessing import LabelEncoder import pandas as pd import numpy as np load_file = open('model.json', "r") loaded_model_json = load_file.read() load_file.close() loaded_model = model_from_json(loaded_model_json) loaded_model.load_weights("model.h5") encoder = LabelEncoder() encoder.classes_ = np.load('encoded_classes.npy') ... ... ... ... #Usually models take numpy not dataframes X_input_cat = np.asarray(X_input_cat) pred = loaded_model.predict_classes(X_input_cat[:,:]) RE: How to use a pmml model in Python - FlamingGuava - Aug-05-2017 (Aug-05-2017, 05:10 AM)radioactive9 Wrote: Hello I haven't saved anything save for a pmml file. The model was already trained in R, and once I trained it I exported it to pmml so that I can try using it in Python. I'm just curious as to how to open the model, run my data through it, and get an output. RE: How to use a pmml model in Python - radioactive9 - Aug-05-2017 Hello Tried to look around. Though I have never worked on PMML and very new to this area of study - but found a github link May be this helps https://github.com/ctrl-alt-d/lightpmmlpredictor |