Icon

kn_​example_​python_​iris_​2021

Simple example to make a random forest model with new Python Scrip in KNIME 4.5 using the iris dataset. Saving and reusing the model with Pickle

Simple example to make a random forest model with new Python Scrip in KNIME 4.5 using the iris dataset. Saving and reusing the model with Pickle
Also creating some graphics and exporting them to disk. Via Python code or via KNIME ports. It is not really necessary to do all this with the colourful ports, just to check how it does work

The sub-folder /data/ conatins "py39_knime_2022.yaml" and "py38_knime_2022.yaml" files to create the Python environments if it would not be installed automaticall by the Conda Environment Propagation. Pleas also check out the additional links provided.

Simple example to make a random forest model with new Python Scrip in KNIME 4.5 using the iris dataset. Saving and reusing the model with PickleAlso creating some graphics and exporting them to disk. Via Python code or via KNIME ports. It is not really necessary to do all this with the colourful ports, just to check how it does workThe sub-folder /data/ conatins "py39_knime_2022.yaml" and "py38_knime_2022.yaml" files to create the Python environments if it would not be installed automaticall by the Conda Environment Propagation. Pleas also check out the additional links provided. # Python Random Forest Learner# import the KNIME moduleimport knime_io as knio#Import Libraryfrom sklearn.ensemble import RandomForestClassifier as RFfrom math import sqrtimport numpy as npimport pandas as pd# recreate the classic input_table from the new Python import since KNIME 4.5input_table = knio.input_tables[0].to_pandas()x_train = input_table.loc[:, input_table.columns != 'Target']y_train = input_table.loc[:, input_table.columns == 'Target']# settings for Random Forests# https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html# https://towardsdatascience.com/hyperparameter-tuning-the-random-forest-in-python-using-scikit-learn-28d2aa77dd74n_trees = 500max_features = int( round( sqrt( x_train.shape[1] ) * 2 )) # try more features at each splitmax_features = 'auto'max_depth = 7verbose = 1n_jobs = 1# user the settings from the variablesoutput_model = RF( n_estimators = n_trees, max_features = max_features, max_depth = max_depth, verbose = verbose, n_jobs = n_jobs )output_model.fit(x_train, y_train)# clean the memorydel x_traindel y_train# garbage collectionimport gcgc.collect()# export the settings into a pandas data frame (to bring it back to KNIME)output_table = pd.DataFrame( { "n_trees" : [n_trees],"max_features" : [max_features],"max_depth" : [max_depth],"verbose" : [verbose], "n_jobs" : [n_jobs] } ) # These are the node's outputs that need to be populated:knio.output_tables[0] = knio.write_table(output_table)knio.output_objects[0] = output_model import pickleimport os# set the path for the pickel filepath = flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'random_forest.pkl'# Save object as pickle file# the input object is the 'old' style to import objedcts into the Python object writerpickle.dump(input_object, open(path, 'wb'), pickle.HIGHEST_PROTOCOL) import knime_io as knio#Import Libraryfrom sklearn.ensemble import RandomForestClassifier as RFfrom math import sqrtimport numpy as npimport pandas as pdinput_table = knio.input_tables[0].to_pandas()input_model = knio.input_objects[0] x_test = input_table.loc[:, input_table.columns != 'Target']y_test = input_table.loc[:, input_table.columns == 'Target']v_indices = input_table.index.values # https://stackoverflow.com/questions/48947194/add-randomforestclassifier-predict-proba-results-to-original-dataframeprediction_of_probability = input_model.predict_proba( x_test )# determine the original classes of the model# https://stackoverflow.com/questions/16858652/how-to-find-the-corresponding-class-in-clf-predict-probav_classes = input_model.classes_# store the prediction in a Data Framedf_prediction = pd.DataFrame(data=prediction_of_probability, # values index=v_indices, # 1st column as index columns=v_classes) # the classes as column names# convert the predictions to float64, this is necessary because # sometimes there were problems with pandas and KNIMEdf_prediction[v_classes] = df_prediction[v_classes ].astype('float64')# put prefix pred_ to the variables to indicate the predictiondf_prediction = df_prediction.add_prefix('pred_')# print(df_prediction)# merge the original table and the predictionoutput_table = input_table.copy()output_table = pd.merge(output_table, df_prediction, left_index=True, right_index=True)# exampels how to keep some ID columns with a prediction if you do not want to keep all columns# output_table = pd.DataFrame(data=np_array, columns=['save_id_txt', 'solution', 'submission'])# output_table = pd.DataFrame(data=np_array, columns=['solution', 'submission'])del x_testdel y_testdel df_predictiondel v_classesimport gcgc.collect()# These are the node's outputs that need to be populated:knio.output_tables[0] = knio.write_table(output_table) import pickleimport os# set the path for the pickel filepath = flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'random_forest.pkl'# Load object from pickle fileoutput_object = pickle.load(open(path, 'rb')) import knime_io as knio#Import Libraryfrom io import BytesIOimport seaborn as snsimport osinput_table = knio.input_tables[0].to_pandas()sns_plot = sns.jointplot(x=input_table['Petal.Length'], y=input_table['Sepal.Width'], fill=True, kind="kde")# Create buffer to write intobuffer = BytesIO()# Create plot and write it into the buffersns_plot.savefig(buffer, format='svg')# The output is the content of the bufferoutput_image = buffer.getvalue()# define paths for PNG and PDF filesvar_path_png = knio.flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'iris_from_python_script.png'var_path_pdf = knio.flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'iris_from_python_script.pdf'# export the PNG and PDF files directly to disksns_plot.savefig(var_path_png, dpi=900, format='png')sns_plot.savefig(var_path_pdf, dpi=900, format='pdf')knio.output_images[0] = output_image import knime_io as knioimport pickleimport os# Path is workspace/python_object.pklpath = knio.flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'random_forest2.pkl'# Load object from pickle fileoutput_object = pickle.load(open(path, 'rb'))# bring the imported onject to the new KNIME Python script styleknio.output_objects[0] = output_object The sub-folder "/data/" contains two YAML files to create Python environments if the automatic Conda Propagation would fail. The version 38 would have a new H2O vesrion wich is not yet compatible with the Python 3.9 version. All versions would be based on the open source "conda-forge" channel and containn the most important libraries to do graphics, data analytics and machine-learning in Python - as well as work witrh the KNIME Pyhon nodes # The sub-folder /data/ conatins a "py39_knime_2022.yaml" file to create the Python environment if it would not be installed automaticall by the Conda Environment Propagation.# KNIME official Python integration guide# https://docs.knime.com/latest/python_installation_guide/index.html#_introduction# Meta collection about KNIME and Python# https://kni.me/w/AvjrddXKOIoZYLV3# use Miniconda and install a basic version (https://docs.conda.io/en/latest/miniconda.html)# Manage Conda environments:# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html# conda remove --name py39_knime --all# KNIME Python Integration - envconfigs# overview of KNIME conda environment configurations (where this YAML file has been adapted from):# https://forum.knime.com/t/an-error-occured-during-training-of-the-keras-deep-learning-network-when-using-knime/38581/15?u=mlauber71# create a conda environment from scratch with this curated yaml file for MacOSX systems - you might have to adapt the path :-)# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_iris_2021/data/py39_knime_2022.yaml"# conda activate py39_knime# conda update -n py39_knime --update-all# conda config --get channels# conda deactivate# conda env list# start jupyter notebook (https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html)# py39_knime>jupyter notebook# KNIME and Deep Learning integration# https://forum.knime.com/t/an-error-occured-during-training-of-the-keras-deep-learning-network-when-using-knime/38581/7?u=mlauber71# overview of KNIME conda environment configurations (where this YAML file has been adapted from):# conda install -c h2oai h2o>=3.36.0.1name: py39_knime # Name of the created environmentchannels: # Repositories to search for packages- conda-forge- h2oaidependencies: # List of packages that should be installed- python=3.9 # Python- pip # for pip dependencies- py4j # used for KNIME <-> Python communication- nomkl # Prevents the use of Intel's MKL- pandas # Table data structures- jedi # Python script autocompletion- python-dateutil # Date and Time utilities- numpy # N-dimensional arrays- cairo # SVG support- pillow # Image inputs/outputs- pyarrow=6.0 # Arrow serialization- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- python-flatbuffers<2.0 # because tensorflow expects a version before 2- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned- protobuf>3.12 # Lower protobuf versions do not work with TensorFlow 2- libiconv # MDF Reader node- asammdf=5.19.14 # MDF Reader node- openpyxl # Excel Reader and Manipulator- sqlite- orc# Machine Learning- scikit-learn # Machine Learning- featuretools # feature generator- pandas-profiling # Data report for exploration- h2o # H2O.ai Machine Learning collection # Visualization- matplotlib # Plotting- bokeh- seaborn# Jupyter- jupyterlab- jupytext- ipywidgets # Interactive Jupyter widgets- nodejs- nbconvert- widgetsnbextension- jupyter_contrib_nbextensions # Jupyter notebook extension- jupyter_nbextensions_configurator # UI for Jupyter notebook extension management- pip: - JPype1 # Databases # - auto-sklearn # - missingno # Missing Value analysis - aquirdturtle_collapsible_headings # JupyterLab collapsible Headings - jupyterlab-code-snippets # JupyterLab Snippets with Tags # The sub-folder /data/ conatins a "py38_knime_2022.yaml" file to create the Python environment if it would not be installed automaticall by the Conda Environment Propagation.# KNIME official Python integration guide# https://docs.knime.com/latest/python_installation_guide/index.html#_introduction# Meta collection about KNIME and Python# https://kni.me/w/AvjrddXKOIoZYLV3# use Miniconda and install a basic version (https://docs.conda.io/en/latest/miniconda.html)# Manage Conda environments:# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html# conda remove --name py38_knime --all# KNIME Python Integration - envconfigs# overview of KNIME conda environment configurations (where this YAML file has been adapted from):# https://forum.knime.com/t/an-error-occured-during-training-of-the-keras-deep-learning-network-when-using-knime/38581/15?u=mlauber71# create a conda environment from scratch with this curated yaml file for MacOSX systems - you might have to adapt the path :-)# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_iris_2021/data/py38_knime_2022.yaml"# conda activate py38_knime# conda update -n py38_knime --update-all# conda config --get channels# conda deactivate# conda env list# start jupyter notebook (https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html)# py38_knime>jupyter notebook# KNIME and Deep Learning integration# https://forum.knime.com/t/an-error-occured-during-training-of-the-keras-deep-learning-network-when-using-knime/38581/7?u=mlauber71# overview of KNIME conda environment configurations (where this YAML file has been adapted from):# conda install -c h2oai h2o>=3.36.0.1name: py38_knime # Name of the created environmentchannels: # Repositories to search for packages- conda-forge- h2oaidependencies: # List of packages that should be installed- python>=3.8,<3.9 # Python- pip # for pip dependencies- py4j # used for KNIME <-> Python communication- nomkl # Prevents the use of Intel's MKL- pandas # Table data structures- jedi # Python script autocompletion- python-dateutil # Date and Time utilities- numpy # N-dimensional arrays- cairo # SVG support- pillow # Image inputs/outputs- pyarrow=6.0 # Arrow serialization- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- python-flatbuffers<2.0 # because tensorflow expects a version before 2- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned- protobuf>3.12 # Lower protobuf versions do not work with TensorFlow 2- libiconv # MDF Reader node- asammdf=5.19.14 # MDF Reader node- openpyxl # Excel Reader and Manipulator- sqlite- orc# Machine Learning- scikit-learn # Machine Learning- featuretools # feature generator- pandas-profiling # Data report for exploration- h2o>=3.36.0.1 # H2O.ai Machine Learning collection # Visualization- matplotlib # Plotting- bokeh- seaborn# Jupyter- jupyterlab- jupytext- ipywidgets # Interactive Jupyter widgets- nodejs- nbconvert- widgetsnbextension- jupyter_contrib_nbextensions # Jupyter notebook extension- jupyter_nbextensions_configurator # UI for Jupyter notebook extension management- pip: - JPype1 # Databases # - auto-sklearn # - missingno # Missing Value analysis - aquirdturtle_collapsible_headings # JupyterLab collapsible Headings - jupyterlab-code-snippets # JupyterLab Snippets with Tags random_forest.pkl=> Targetsplitrandom_forest.pkldeterminepath and name of workflowconda.environmentpy39_knimeiris.tablePython Learneroutput the tree settings as knime tablePython Predictorrandom_forest2.pklrandom_forest2.pkl1.024x768PNG file../data/iris_from_knime.pngkde plotusing seaborn packageexport to../data/iris_from_python_script.png../data/iris_from_python_script.pdfiris.parquetconda.environmentpy38_knimeflow_variables['var_py_version_pandas'] = pd.__version__flow_variables['var_py_version_numpy'] = np.__version__Python ObjectWriter Column Rename Partitioning Python ObjectReader Extract ContextProperties Conda EnvironmentPropagation Merge Variables Table Reader Python Script(Labs) Python Script(Labs) determine paths Python Script(Labs) Python Script(Labs) Merge Variables Image To Table Renderer to Image Table To Image Image Writer (Port) Python Script(Labs) Merge Variables Parquet Writer Conda EnvironmentPropagation Python EditVariable Simple example to make a random forest model with new Python Scrip in KNIME 4.5 using the iris dataset. Saving and reusing the model with PickleAlso creating some graphics and exporting them to disk. Via Python code or via KNIME ports. It is not really necessary to do all this with the colourful ports, just to check how it does workThe sub-folder /data/ conatins "py39_knime_2022.yaml" and "py38_knime_2022.yaml" files to create the Python environments if it would not be installed automaticall by the Conda Environment Propagation. Pleas also check out the additional links provided. # Python Random Forest Learner# import the KNIME moduleimport knime_io as knio#Import Libraryfrom sklearn.ensemble import RandomForestClassifier as RFfrom math import sqrtimport numpy as npimport pandas as pd# recreate the classic input_table from the new Python import since KNIME 4.5input_table = knio.input_tables[0].to_pandas()x_train = input_table.loc[:, input_table.columns != 'Target']y_train = input_table.loc[:, input_table.columns == 'Target']# settings for Random Forests# https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html# https://towardsdatascience.com/hyperparameter-tuning-the-random-forest-in-python-using-scikit-learn-28d2aa77dd74n_trees = 500max_features = int( round( sqrt( x_train.shape[1] ) * 2 )) # try more features at each splitmax_features = 'auto'max_depth = 7verbose = 1n_jobs = 1# user the settings from the variablesoutput_model = RF( n_estimators = n_trees, max_features = max_features, max_depth = max_depth, verbose = verbose, n_jobs = n_jobs )output_model.fit(x_train, y_train)# clean the memorydel x_traindel y_train# garbage collectionimport gcgc.collect()# export the settings into a pandas data frame (to bring it back to KNIME)output_table = pd.DataFrame( { "n_trees" : [n_trees],"max_features" : [max_features],"max_depth" : [max_depth],"verbose" : [verbose], "n_jobs" : [n_jobs] } ) # These are the node's outputs that need to be populated:knio.output_tables[0] = knio.write_table(output_table)knio.output_objects[0] = output_model import pickleimport os# set the path for the pickel filepath = flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'random_forest.pkl'# Save object as pickle file# the input object is the 'old' style to import objedcts into the Python object writerpickle.dump(input_object, open(path, 'wb'), pickle.HIGHEST_PROTOCOL) import knime_io as knio#Import Libraryfrom sklearn.ensemble import RandomForestClassifier as RFfrom math import sqrtimport numpy as npimport pandas as pdinput_table = knio.input_tables[0].to_pandas()input_model = knio.input_objects[0] x_test = input_table.loc[:, input_table.columns != 'Target']y_test = input_table.loc[:, input_table.columns == 'Target']v_indices = input_table.index.values # https://stackoverflow.com/questions/48947194/add-randomforestclassifier-predict-proba-results-to-original-dataframeprediction_of_probability = input_model.predict_proba( x_test )# determine the original classes of the model# https://stackoverflow.com/questions/16858652/how-to-find-the-corresponding-class-in-clf-predict-probav_classes = input_model.classes_# store the prediction in a Data Framedf_prediction = pd.DataFrame(data=prediction_of_probability, # values index=v_indices, # 1st column as index columns=v_classes) # the classes as column names# convert the predictions to float64, this is necessary because # sometimes there were problems with pandas and KNIMEdf_prediction[v_classes] = df_prediction[v_classes ].astype('float64')# put prefix pred_ to the variables to indicate the predictiondf_prediction = df_prediction.add_prefix('pred_')# print(df_prediction)# merge the original table and the predictionoutput_table = input_table.copy()output_table = pd.merge(output_table, df_prediction, left_index=True, right_index=True)# exampels how to keep some ID columns with a prediction if you do not want to keep all columns# output_table = pd.DataFrame(data=np_array, columns=['save_id_txt', 'solution', 'submission'])# output_table = pd.DataFrame(data=np_array, columns=['solution', 'submission'])del x_testdel y_testdel df_predictiondel v_classesimport gcgc.collect()# These are the node's outputs that need to be populated:knio.output_tables[0] = knio.write_table(output_table) import pickleimport os# set the path for the pickel filepath = flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'random_forest.pkl'# Load object from pickle fileoutput_object = pickle.load(open(path, 'rb')) import knime_io as knio#Import Libraryfrom io import BytesIOimport seaborn as snsimport osinput_table = knio.input_tables[0].to_pandas()sns_plot = sns.jointplot(x=input_table['Petal.Length'], y=input_table['Sepal.Width'], fill=True, kind="kde")# Create buffer to write intobuffer = BytesIO()# Create plot and write it into the buffersns_plot.savefig(buffer, format='svg')# The output is the content of the bufferoutput_image = buffer.getvalue()# define paths for PNG and PDF filesvar_path_png = knio.flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'iris_from_python_script.png'var_path_pdf = knio.flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'iris_from_python_script.pdf'# export the PNG and PDF files directly to disksns_plot.savefig(var_path_png, dpi=900, format='png')sns_plot.savefig(var_path_pdf, dpi=900, format='pdf')knio.output_images[0] = output_image import knime_io as knioimport pickleimport os# Path is workspace/python_object.pklpath = knio.flow_variables['var_path_workflow_absolute'] + os.sep + 'data' + os.sep + 'random_forest2.pkl'# Load object from pickle fileoutput_object = pickle.load(open(path, 'rb'))# bring the imported onject to the new KNIME Python script styleknio.output_objects[0] = output_object The sub-folder "/data/" contains two YAML files to create Python environments if the automatic Conda Propagation would fail. The version 38 would have a new H2O vesrion wich is not yet compatible with the Python 3.9 version. All versions would be based on the open source "conda-forge" channel and containn the most important libraries to do graphics, data analytics and machine-learning in Python - as well as work witrh the KNIME Pyhon nodes # The sub-folder /data/ conatins a "py39_knime_2022.yaml" file to create the Python environment if it would not be installed automaticall by the Conda Environment Propagation.# KNIME official Python integration guide# https://docs.knime.com/latest/python_installation_guide/index.html#_introduction# Meta collection about KNIME and Python# https://kni.me/w/AvjrddXKOIoZYLV3# use Miniconda and install a basic version (https://docs.conda.io/en/latest/miniconda.html)# Manage Conda environments:# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html# conda remove --name py39_knime --all# KNIME Python Integration - envconfigs# overview of KNIME conda environment configurations (where this YAML file has been adapted from):# https://forum.knime.com/t/an-error-occured-during-training-of-the-keras-deep-learning-network-when-using-knime/38581/15?u=mlauber71# create a conda environment from scratch with this curated yaml file for MacOSX systems - you might have to adapt the path :-)# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_iris_2021/data/py39_knime_2022.yaml"# conda activate py39_knime# conda update -n py39_knime --update-all# conda config --get channels# conda deactivate# conda env list# start jupyter notebook (https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html)# py39_knime>jupyter notebook# KNIME and Deep Learning integration# https://forum.knime.com/t/an-error-occured-during-training-of-the-keras-deep-learning-network-when-using-knime/38581/7?u=mlauber71# overview of KNIME conda environment configurations (where this YAML file has been adapted from):# conda install -c h2oai h2o>=3.36.0.1name: py39_knime # Name of the created environmentchannels: # Repositories to search for packages- conda-forge- h2oaidependencies: # List of packages that should be installed- python=3.9 # Python- pip # for pip dependencies- py4j # used for KNIME <-> Python communication- nomkl # Prevents the use of Intel's MKL- pandas # Table data structures- jedi # Python script autocompletion- python-dateutil # Date and Time utilities- numpy # N-dimensional arrays- cairo # SVG support- pillow # Image inputs/outputs- pyarrow=6.0 # Arrow serialization- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- python-flatbuffers<2.0 # because tensorflow expects a version before 2- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned- protobuf>3.12 # Lower protobuf versions do not work with TensorFlow 2- libiconv # MDF Reader node- asammdf=5.19.14 # MDF Reader node- openpyxl # Excel Reader and Manipulator- sqlite- orc# Machine Learning- scikit-learn # Machine Learning- featuretools # feature generator- pandas-profiling # Data report for exploration- h2o # H2O.ai Machine Learning collection # Visualization- matplotlib # Plotting- bokeh- seaborn# Jupyter- jupyterlab- jupytext- ipywidgets # Interactive Jupyter widgets- nodejs- nbconvert- widgetsnbextension- jupyter_contrib_nbextensions # Jupyter notebook extension- jupyter_nbextensions_configurator # UI for Jupyter notebook extension management- pip: - JPype1 # Databases # - auto-sklearn # - missingno # Missing Value analysis - aquirdturtle_collapsible_headings # JupyterLab collapsible Headings - jupyterlab-code-snippets # JupyterLab Snippets with Tags # The sub-folder /data/ conatins a "py38_knime_2022.yaml" file to create the Python environment if it would not be installed automaticall by the Conda Environment Propagation.# KNIME official Python integration guide# https://docs.knime.com/latest/python_installation_guide/index.html#_introduction# Meta collection about KNIME and Python# https://kni.me/w/AvjrddXKOIoZYLV3# use Miniconda and install a basic version (https://docs.conda.io/en/latest/miniconda.html)# Manage Conda environments:# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html# conda remove --name py38_knime --all# KNIME Python Integration - envconfigs# overview of KNIME conda environment configurations (where this YAML file has been adapted from):# https://forum.knime.com/t/an-error-occured-during-training-of-the-keras-deep-learning-network-when-using-knime/38581/15?u=mlauber71# create a conda environment from scratch with this curated yaml file for MacOSX systems - you might have to adapt the path :-)# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_python_iris_2021/data/py38_knime_2022.yaml"# conda activate py38_knime# conda update -n py38_knime --update-all# conda config --get channels# conda deactivate# conda env list# start jupyter notebook (https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html)# py38_knime>jupyter notebook# KNIME and Deep Learning integration# https://forum.knime.com/t/an-error-occured-during-training-of-the-keras-deep-learning-network-when-using-knime/38581/7?u=mlauber71# overview of KNIME conda environment configurations (where this YAML file has been adapted from):# conda install -c h2oai h2o>=3.36.0.1name: py38_knime # Name of the created environmentchannels: # Repositories to search for packages- conda-forge- h2oaidependencies: # List of packages that should be installed- python>=3.8,<3.9 # Python- pip # for pip dependencies- py4j # used for KNIME <-> Python communication- nomkl # Prevents the use of Intel's MKL- pandas # Table data structures- jedi # Python script autocompletion- python-dateutil # Date and Time utilities- numpy # N-dimensional arrays- cairo # SVG support- pillow # Image inputs/outputs- pyarrow=6.0 # Arrow serialization- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- python-flatbuffers<2.0 # because tensorflow expects a version before 2- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned- protobuf>3.12 # Lower protobuf versions do not work with TensorFlow 2- libiconv # MDF Reader node- asammdf=5.19.14 # MDF Reader node- openpyxl # Excel Reader and Manipulator- sqlite- orc# Machine Learning- scikit-learn # Machine Learning- featuretools # feature generator- pandas-profiling # Data report for exploration- h2o>=3.36.0.1 # H2O.ai Machine Learning collection # Visualization- matplotlib # Plotting- bokeh- seaborn# Jupyter- jupyterlab- jupytext- ipywidgets # Interactive Jupyter widgets- nodejs- nbconvert- widgetsnbextension- jupyter_contrib_nbextensions # Jupyter notebook extension- jupyter_nbextensions_configurator # UI for Jupyter notebook extension management- pip: - JPype1 # Databases # - auto-sklearn # - missingno # Missing Value analysis - aquirdturtle_collapsible_headings # JupyterLab collapsible Headings - jupyterlab-code-snippets # JupyterLab Snippets with Tags random_forest.pkl=> Targetsplitrandom_forest.pkldeterminepath and name of workflowconda.environmentpy39_knimeiris.tablePython Learneroutput the tree settings as knime tablePython Predictorrandom_forest2.pklrandom_forest2.pkl1.024x768PNG file../data/iris_from_knime.pngkde plotusing seaborn packageexport to../data/iris_from_python_script.png../data/iris_from_python_script.pdfiris.parquetconda.environmentpy38_knimeflow_variables['var_py_version_pandas'] = pd.__version__flow_variables['var_py_version_numpy'] = np.__version__Python ObjectWriter Column Rename Partitioning Python ObjectReader Extract ContextProperties Conda EnvironmentPropagation Merge Variables Table Reader Python Script(Labs) Python Script(Labs) determine paths Python Script(Labs) Python Script(Labs) Merge Variables Image To Table Renderer to Image Table To Image Image Writer (Port) Python Script(Labs) Merge Variables Parquet Writer Conda EnvironmentPropagation Python EditVariable

Nodes

Extensions

Links