Icon

kn_​deeplearn_​100_​keras_​basic

a simple deep learning network for binary classification using the KNIME Keras integration (with a Python environment propagation)

a simple deep learning network for binary classification using the KNIME Keras integration (with a Python environment propagation)
Please note this example should demonstrate how to set up the deep learning environment with Keras and provide a working simple example.

Adapted from: https://kni.me/w/Cm0lqIKkvThyHAD-
"This workflow trains a fully connected, feedforward network using the adult dataset."

please download the complete DeepLearning (Keras, Tensorflow, H2O.ai) Workflow group:
https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_deeplearning_keras_tensorflow_classification~G8jl-DTMCBqoxyB9/



Define network strucuture and train the network. Please note: this is just an example.You might have to come up with your own architecture. Apply trained network and extract predictions # Python 3.6 / 3.7 with Keras (MacOSX)# KNIME and Python — Setting up and managing Conda environments# https://medium.com/@mlxl/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539# conda update -n base -c conda-forge conda# conda env create -f="C:\Users\a123456789\knime-workspace\hub\kn_example_deeplearning_keras_tensorflow_classification\data\knime_py_keras_macos.yml"# conda remove --name knime_py_keras_macos --all# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_deeplearning_keras_tensorflow_classification/data/knime_py_keras_macos.yml"# conda activate knime_py_keras_macos# conda update -n knime_py_keras_macos --update-all# conda env update -n knime_py_keras_macos --file="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_deeplearning_keras_tensorflow_classification/data/knime_py_keras_macos.yml"# conda config --get channels# conda deactivate# conda install -c conda-forge h5py=2.8 keras=2.2.4# pip install onnx==1.4.1# pip install onnx-tf==1.2.1# conda install -c conda-forge onnx-tf# if the above does fail try:# conda install -n knime_py_keras_macos -c esri onnx-tf# conda install -n knime_py_keras_macos -c conda-forge onnx# conda install -n knime_py_keras_macos -c conda-forge tensorflow==1.14# conda update -n knime_py_keras_macos --update-allname: knime_py_keras_macos # Name of the created environmentchannels: # Repositories to search for packages# - defaults # edit: removed to just use conda-forge# - anaconda # edit: removed to just use conda-forge- conda-forgedependencies: # List of packages that should be installed- python>=3.6 # Python- py4j # uesd for KNIME <-> Python communication- nomkl # Prevents the use of Intel's MKL- pandas # Table data structures- jedi<=0.17.2 # Python script autocompletion- python-dateutil # Date and Time utilities- numpy>=1.15 # N-dimensional arrays- cairo # SVG support- pillow # Image inputs/outputs# - matplotlib # Plotting- pyarrow=6.0 # Arrow serialization- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- jpype1 # Databases- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned- libiconv # MDF Reader node- asammdf=5.19.14 # MDF Reader node# somtimes there seems to be a bit of a drama with tensorflow and Keras versions. You might have to do this by hand# pip uninstall tensorflow# https://github.com/tensorflow/tensorflow/issues/51590# conda install -n knime_py_keras_macos -c conda-forge tensorflow==1.14 # serach for the available package versions on conda-forge# conda search conda-forge::tensorflow# conda list -n knime_py_keras_macos -f tensorflow --json# conda install -n knime_py_keras_macos -c conda-forge tensorflow==1.14- tensorflow==1.14 # TensorFlow has to be a number close to 1.12# - tensorflow-mkl==1.14- tensorflow-estimator==1.14 # or mac will install 2.6 which doesn't work- tensorflow-hub- keras==2.2.4- pip # Python installer- pip: - onnx # ==1.4.1 - onnx-tf # ==1.2.1 # https://github.com/tensorflow/tensorflow/issues/51590#issuecomment-1010305647 - flatbuffers==1.12 # - tensorflow==1.13.1 # - tensorflow-mkl==1.12 # - keras==2.2.4 a simple deep learning network for binary classification using the KNIME Keras integration (with a Python environment propagation)Please note this example should demonstrate how to set up the deep learning environment with Keras and provide a working simple example.Adapted from: https://kni.me/w/Cm0lqIKkvThyHAD-"This workflow trains a fully connected, feedforward network using the adult dataset."please download the complete DeepLearning (Keras, Tensorflow, H2O.ai) Workflow group:https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_deeplearning_keras_tensorflow_classification~G8jl-DTMCBqoxyB9/ these nodes should make sure you have a running Keras / Deep Learning ready Python environment in Windowsor MacOSX if the complicated Model Quality Metanode does not work you can stick to the"Binary Classification Inspector" node If the Environment Propagation does fail you can manually install the Python environment with these steps in Windows and MacOSX # Python 3.6 / 3.7 with Keras (Windows)# KNIME and Python — Setting up and managing Conda environments# https://medium.com/@mlxl/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539# conda update -n base -c conda-forge conda# conda env create -f="C:\Users\a123456789\knime-workspace\hub\kn_example_deeplearning_keras_tensorflow_classification\data\knime_py_keras_win.yml"# conda remove --name knime_py_keras_win --all# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_deeplearning_keras_tensorflow_classification/data/knime_py_keras_win.yml"# conda activate knime_py_keras_win# conda update -n knime_py_keras_win --update-all# conda env update -n knime_py_keras_win --file="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_deeplearning_keras_tensorflow_classification/data/knime_py_keras_win.yml"# conda config --get channels# conda deactivate# conda install -c conda-forge h5py=2.8 keras=2.2.4# pip install onnx==1.4.1# pip install onnx-tf==1.2.1# conda install -c conda-forge onnx-tf# if the above does fail try:# conda install -n knime_py_keras_win -c esri onnx-tf# conda install -n knime_py_keras_win -c conda-forge onnx# conda install -n knime_py_keras_win -c conda-forge tensorflow==1.14# conda update -n knime_py_keras_win --update-allname: knime_py_keras_win # Name of the created environmentchannels: # Repositories to search for packages# - defaults # edit: removed to just use conda-forge# - anaconda # edit: removed to just use conda-forge- conda-forgedependencies: # List of packages that should be installed- python>=3.6 # Python- py4j # uesd for KNIME <-> Python communication- nomkl # Prevents the use of Intel's MKL- pandas # Table data structures- jedi<=0.17.2 # Python script autocompletion- python-dateutil # Date and Time utilities- numpy>=1.15 # N-dimensional arrays- cairo # SVG support- pillow # Image inputs/outputs# - matplotlib # Plotting- pyarrow=6.0 # Arrow serialization- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- jpype1 # Databases- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned- libiconv # MDF Reader node- asammdf=5.19.14 # MDF Reader node# somtimes there seems to be a bit of a drama with tensorflow and Keras versions. You might have to do this by hand# pip uninstall tensorflow# https://github.com/tensorflow/tensorflow/issues/51590# conda install -n knime_py_keras_win -c conda-forge tensorflow==1.14 # serach for the available package versions on conda-forge# conda search conda-forge::tensorflow# conda list -n knime_py_keras_win -f tensorflow --json# conda install -n knime_py_keras_win -c conda-forge tensorflow==1.14- tensorflow==1.14 # TensorFlow has to be a number close to 1.12# - tensorflow-mkl==1.14- tensorflow-estimator==1.14 # or mac will install 2.6 which doesn't work- tensorflow-hub- keras==2.2.4- pip # Python installer- pip: - onnx # ==1.4.1 - onnx-tf # ==1.2.1 # https://github.com/tensorflow/tensorflow/issues/51590#issuecomment-1010305647 - flatbuffers==1.12 # - tensorflow==1.13.1 # - tensorflow-mkl==1.12 # - keras==2.2.4 # you will need a working Miniforge or Miniconda installation# please note - the popular Anaconda package has changed its licensing recently. # So make sure you comply with that. Or use Miniforge with conda-forge for the time being# https://docs.conda.io/en/latest/miniconda.html# check the conda environmentsconda info --envsKNIME and Python — Setting up and managing Conda environmentshttps://medium.com/@mlxl/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539KNIME Python Integration Guidehttps://docs.knime.com/latest/python_installation_guide/index.html#_introductionMeta Collection about KNIME and Pythonhttps://kni.me/w/AvjrddXKOIoZYLV3KNIME Deep Learning Integration Installation Guidehttps://docs.knime.com/latest/deep_learning_installation_guide/index.html#_introduction Propagate R environmentfor KNIME on MacOS withMinicondaconfigure how to handle the environmentdefault = just check the names../data/deep_001_training.table Write modelknime://knime.workflow/../model/adult_keras_basic.h5apply trainednetworkReLU, 6 UnitsInputsthe number of inputs is dynamically basedon the number of variablesSigmoid; 1 UnitRelu; 6 Unitstrain=> convert binary/string target tonumber../data/deep_005_test.table../data/deep_009_validate.tabletestvalidatesolutionto string^(.*submission|solution).*$get the numberof feature columnsbinary classification modelswith R. Results:/model/validation/number of RowsNumber (double)knime://knime.workflow/../model/adult_keras_basic.h5Propagate R environmentfor KNIME on Windows withMiniforge / Minicondaconfigure how to handle the environmentdefault = just check the nameskeras.conda.environmentknime_py_keras_macos=> for MacOS environmentkeras.conda.environmentknime_py_keras_win=> for Windows environmentknime_r_environment Table Reader Keras NetworkWriter Keras NetworkLearner Keras NetworkExecutor Keras Dense Layer Keras Input Layer Keras Dense Layer Keras Dense Layer String ToNumber (PMML) Table Reader Table Reader PMML TransformationApply PMML TransformationApply Number To String Column Filter Column Rename Extract Table Spec GroupBy RowID Table Columnto Variable Model QualityClassification - Graphics Binary ClassificationInspector Extract TableDimension Table Columnto Variable collect meta data Row Filter Keras NetworkReader knime_r_environment_windows knime_py_keras_macos knime_py_keras_win Define network strucuture and train the network. Please note: this is just an example.You might have to come up with your own architecture. Apply trained network and extract predictions # Python 3.6 / 3.7 with Keras (MacOSX)# KNIME and Python — Setting up and managing Conda environments# https://medium.com/@mlxl/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539# conda update -n base -c conda-forge conda# conda env create -f="C:\Users\a123456789\knime-workspace\hub\kn_example_deeplearning_keras_tensorflow_classification\data\knime_py_keras_macos.yml"# conda remove --name knime_py_keras_macos --all# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_deeplearning_keras_tensorflow_classification/data/knime_py_keras_macos.yml"# conda activate knime_py_keras_macos# conda update -n knime_py_keras_macos --update-all# conda env update -n knime_py_keras_macos --file="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_deeplearning_keras_tensorflow_classification/data/knime_py_keras_macos.yml"# conda config --get channels# conda deactivate# conda install -c conda-forge h5py=2.8 keras=2.2.4# pip install onnx==1.4.1# pip install onnx-tf==1.2.1# conda install -c conda-forge onnx-tf# if the above does fail try:# conda install -n knime_py_keras_macos -c esri onnx-tf# conda install -n knime_py_keras_macos -c conda-forge onnx# conda install -n knime_py_keras_macos -c conda-forge tensorflow==1.14# conda update -n knime_py_keras_macos --update-allname: knime_py_keras_macos # Name of the created environmentchannels: # Repositories to search for packages# - defaults # edit: removed to just use conda-forge# - anaconda # edit: removed to just use conda-forge- conda-forgedependencies: # List of packages that should be installed- python>=3.6 # Python- py4j # uesd for KNIME <-> Python communication- nomkl # Prevents the use of Intel's MKL- pandas # Table data structures- jedi<=0.17.2 # Python script autocompletion- python-dateutil # Date and Time utilities- numpy>=1.15 # N-dimensional arrays- cairo # SVG support- pillow # Image inputs/outputs# - matplotlib # Plotting- pyarrow=6.0 # Arrow serialization- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- jpype1 # Databases- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned- libiconv # MDF Reader node- asammdf=5.19.14 # MDF Reader node# somtimes there seems to be a bit of a drama with tensorflow and Keras versions. You might have to do this by hand# pip uninstall tensorflow# https://github.com/tensorflow/tensorflow/issues/51590# conda install -n knime_py_keras_macos -c conda-forge tensorflow==1.14 # serach for the available package versions on conda-forge# conda search conda-forge::tensorflow# conda list -n knime_py_keras_macos -f tensorflow --json# conda install -n knime_py_keras_macos -c conda-forge tensorflow==1.14- tensorflow==1.14 # TensorFlow has to be a number close to 1.12# - tensorflow-mkl==1.14- tensorflow-estimator==1.14 # or mac will install 2.6 which doesn't work- tensorflow-hub- keras==2.2.4- pip # Python installer- pip: - onnx # ==1.4.1 - onnx-tf # ==1.2.1 # https://github.com/tensorflow/tensorflow/issues/51590#issuecomment-1010305647 - flatbuffers==1.12 # - tensorflow==1.13.1 # - tensorflow-mkl==1.12 # - keras==2.2.4 a simple deep learning network for binary classification using the KNIME Keras integration (with a Python environment propagation)Please note this example should demonstrate how to set up the deep learning environment with Keras and provide a working simple example.Adapted from: https://kni.me/w/Cm0lqIKkvThyHAD-"This workflow trains a fully connected, feedforward network using the adult dataset."please download the complete DeepLearning (Keras, Tensorflow, H2O.ai) Workflow group:https://hub.knime.com/mlauber71/spaces/Public/latest/kn_example_deeplearning_keras_tensorflow_classification~G8jl-DTMCBqoxyB9/ these nodes should make sure you have a running Keras / Deep Learning ready Python environment in Windowsor MacOSX if the complicated Model Quality Metanode does not work you can stick to the"Binary Classification Inspector" node If the Environment Propagation does fail you can manually install the Python environment with these steps in Windows and MacOSX # Python 3.6 / 3.7 with Keras (Windows)# KNIME and Python — Setting up and managing Conda environments# https://medium.com/@mlxl/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539# conda update -n base -c conda-forge conda# conda env create -f="C:\Users\a123456789\knime-workspace\hub\kn_example_deeplearning_keras_tensorflow_classification\data\knime_py_keras_win.yml"# conda remove --name knime_py_keras_win --all# conda env create -f="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_deeplearning_keras_tensorflow_classification/data/knime_py_keras_win.yml"# conda activate knime_py_keras_win# conda update -n knime_py_keras_win --update-all# conda env update -n knime_py_keras_win --file="/Users/m_lauber/Dropbox/knime-workspace/hub/kn_example_deeplearning_keras_tensorflow_classification/data/knime_py_keras_win.yml"# conda config --get channels# conda deactivate# conda install -c conda-forge h5py=2.8 keras=2.2.4# pip install onnx==1.4.1# pip install onnx-tf==1.2.1# conda install -c conda-forge onnx-tf# if the above does fail try:# conda install -n knime_py_keras_win -c esri onnx-tf# conda install -n knime_py_keras_win -c conda-forge onnx# conda install -n knime_py_keras_win -c conda-forge tensorflow==1.14# conda update -n knime_py_keras_win --update-allname: knime_py_keras_win # Name of the created environmentchannels: # Repositories to search for packages# - defaults # edit: removed to just use conda-forge# - anaconda # edit: removed to just use conda-forge- conda-forgedependencies: # List of packages that should be installed- python>=3.6 # Python- py4j # uesd for KNIME <-> Python communication- nomkl # Prevents the use of Intel's MKL- pandas # Table data structures- jedi<=0.17.2 # Python script autocompletion- python-dateutil # Date and Time utilities- numpy>=1.15 # N-dimensional arrays- cairo # SVG support- pillow # Image inputs/outputs# - matplotlib # Plotting- pyarrow=6.0 # Arrow serialization- IPython # Notebook support- nbformat # Notebook support- scipy # Notebook support- jpype1 # Databases- h5py<3.0 # must be < 3.0 because they changed whether str or byte is returned- libiconv # MDF Reader node- asammdf=5.19.14 # MDF Reader node# somtimes there seems to be a bit of a drama with tensorflow and Keras versions. You might have to do this by hand# pip uninstall tensorflow# https://github.com/tensorflow/tensorflow/issues/51590# conda install -n knime_py_keras_win -c conda-forge tensorflow==1.14 # serach for the available package versions on conda-forge# conda search conda-forge::tensorflow# conda list -n knime_py_keras_win -f tensorflow --json# conda install -n knime_py_keras_win -c conda-forge tensorflow==1.14- tensorflow==1.14 # TensorFlow has to be a number close to 1.12# - tensorflow-mkl==1.14- tensorflow-estimator==1.14 # or mac will install 2.6 which doesn't work- tensorflow-hub- keras==2.2.4- pip # Python installer- pip: - onnx # ==1.4.1 - onnx-tf # ==1.2.1 # https://github.com/tensorflow/tensorflow/issues/51590#issuecomment-1010305647 - flatbuffers==1.12 # - tensorflow==1.13.1 # - tensorflow-mkl==1.12 # - keras==2.2.4 # you will need a working Miniforge or Miniconda installation# please note - the popular Anaconda package has changed its licensing recently. # So make sure you comply with that. Or use Miniforge with conda-forge for the time being# https://docs.conda.io/en/latest/miniconda.html# check the conda environmentsconda info --envsKNIME and Python — Setting up and managing Conda environmentshttps://medium.com/@mlxl/knime-and-python-setting-up-and-managing-conda-environments-2ac217792539KNIME Python Integration Guidehttps://docs.knime.com/latest/python_installation_guide/index.html#_introductionMeta Collection about KNIME and Pythonhttps://kni.me/w/AvjrddXKOIoZYLV3KNIME Deep Learning Integration Installation Guidehttps://docs.knime.com/latest/deep_learning_installation_guide/index.html#_introduction Propagate R environmentfor KNIME on MacOS withMinicondaconfigure how to handle the environmentdefault = just check the names../data/deep_001_training.table Write modelknime://knime.workflow/../model/adult_keras_basic.h5apply trainednetworkReLU, 6 UnitsInputsthe number of inputs is dynamically basedon the number of variablesSigmoid; 1 UnitRelu; 6 Unitstrain=> convert binary/string target tonumber../data/deep_005_test.table../data/deep_009_validate.tabletestvalidatesolutionto string^(.*submission|solution).*$get the numberof feature columnsbinary classification modelswith R. Results:/model/validation/number of RowsNumber (double)knime://knime.workflow/../model/adult_keras_basic.h5Propagate R environmentfor KNIME on Windows withMiniforge / Minicondaconfigure how to handle the environmentdefault = just check the nameskeras.conda.environmentknime_py_keras_macos=> for MacOS environmentkeras.conda.environmentknime_py_keras_win=> for Windows environmentknime_r_environment Table Reader Keras NetworkWriter Keras NetworkLearner Keras NetworkExecutor Keras Dense Layer Keras Input Layer Keras Dense Layer Keras Dense Layer String ToNumber (PMML) Table Reader Table Reader PMML TransformationApply PMML TransformationApply Number To String Column Filter Column Rename Extract Table Spec GroupBy RowID Table Columnto Variable Model QualityClassification - Graphics Binary ClassificationInspector Extract TableDimension Table Columnto Variable collect meta data Row Filter Keras NetworkReader knime_r_environment_windows knime_py_keras_macos knime_py_keras_win

Nodes

Extensions

Links