Running Python Script Gives Error

I am fairly new to Knime and Python and I was checking some codes in Python that I would like to run on Python Script Node through Knime. The script executes fine through the node but not outside it, plus, the data does not show correctly on output panel for “Poisson Model” attribute on following script:

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn
from scipy.stats import poisson,skellam
import statsmodels.api as sm
import statsmodels.formula.api as smf


epl_1617 = input_table


poisson_model = smf.glm(formula="input_table['GOALS'] ~ 
input_table['HOME'] + input_table['HomeTeam'] + 
input_table['AwayTeam']", data=epl_1617, 
                    family=sm.families.Poisson()).fit()

poisson_model.summary()

When I run the above code on Python it gives the result in form of a table; however, in Knime the output is shown as "poisson_model: "

Note: the input file can be downloaded from:

http://www.football-data.co.uk/mmz4281/1617/E0.csv

Any idea on how to run the following code on Knime?

Your help is already appreciated!

Question is what kind of output you would expect. KNIME and Python would typically have three generic outputs

  1. data manipulations etc using Python
  2. build prediction models and save them
  3. use graphic packages like seaborn and export graphics (as PNG)

I modified an earlier example to show all three (if you just save results from Python you might use much more), and also there is the ability to integrate Jupyter notebooks in KNIME.

kn_example_python_logistic_regression_iris_graphic.knwf (259.7 KB)

2 Likes