Training ML model using Knime

Hello,

How do I convert Strings to Vectors (Numerical Representation) and apply TF-IDF Vectorizer
Later Using RandomForeset Classifier Need to Train Model with the data in order to Classify the String weather it is True Positive or False Positive.
is there any possibility that it can be done in Knime

below is the Snip for reference (Code in Python)

Thanks & Regards,
Nune Ashok

Hi,
Please have a look at the following workflow: Text Mining Course: Classification – KNIME Community Hub. It does approximately what you need.
Kind regards,
Alexander

Hi @AlexanderFillbrunn thank you for the workflow
i am getting error as Execute failed: Cannot invoke “java.net.URL.getPath()” because “fileUrl” is null while converting String to Document
i checked the string to Document node i don’t see fileurl
also uninstalled Knime & re installed Knime
still same issue

@Ashok121 I think the links shows you the exercise - you might want to take a look at the solution. Maybe you also want to take the text mining course “[L4-TP] Introduction to Text Processing” or take a look at the slides.

Text Mining Course: Classification (solution)

Course Slides: KNIME Course Material Download Page | KNIME

for Text Mining:

@mlauber71 Thank you for the information
but I do see some bug in String to Document Node while I am converting String to Document, I am getting error as Cannot invoke “java.net.URL.getPath()” because “file URL.

1 Like

@Ashok121 you might have to download the data or maybe the whole Workflow Group

Downloaded Entire Workflow still i am getting same Error as ERROR Strings To Document 3:119 Execute failed: Cannot invoke “java.net.URL.getPath()” because “fileUrl” is null

i dont see file url option in string to document

Hello @laaaarsi below is the Error info for String to document
2023-07-01 19:22:06,012 : ERROR : KNIME-Worker-49-Strings To Document 3:119 : : Node : Strings To Document : 3:119 : Execute failed: Cannot invoke “java.net.URL.getPath()” because “fileUrl” is null
java.lang.NullPointerException: Cannot invoke “java.net.URL.getPath()” because “fileUrl” is null
at org.knime.ext.textprocessing.TextprocessingCorePlugin.resolvePath(TextprocessingCorePlugin.java:122)
at org.knime.ext.textprocessing.util.OpenNlpModelPaths.getEnTokenizerModelFile(OpenNlpModelPaths.java:118)
at org.knime.ext.textprocessing.nodes.tokenization.tokenizer.word.OpenNlpEnglishWordTokenizer.(OpenNlpEnglishWordTokenizer.java:81)
at org.knime.ext.textprocessing.nodes.tokenization.tokenizer.word.OpenNlpEnglishWordTokenizerFactory.getTokenizer(OpenNlpEnglishWordTokenizerFactory.java:73)
at org.knime.ext.textprocessing.nodes.tokenization.TokenizerPool.(TokenizerPool.java:97)
at org.knime.ext.textprocessing.nodes.tokenization.DefaultTokenization.createTokenizerPool(DefaultTokenization.java:73)
at org.knime.ext.textprocessing.nodes.tokenization.DefaultTokenization.lambda$1(DefaultTokenization.java:92)
at java.base/java.util.HashMap.computeIfAbsent(Unknown Source)
at org.knime.ext.textprocessing.nodes.tokenization.DefaultTokenization.getWordTokenizer(DefaultTokenization.java:92)
at org.knime.ext.textprocessing.data.DocumentBuilder.(DocumentBuilder.java:135)
at org.knime.ext.textprocessing.nodes.transformation.stringstodocument.StringsToDocumentCellFactory2.getCells(StringsToDocumentCellFactory2.java:163)
at org.knime.core.data.container.RearrangeColumnsTable.calcNewCellsForRow(RearrangeColumnsTable.java:575)
at org.knime.core.data.container.RearrangeColumnsTable$ConcurrentNewColCalculator.compute(RearrangeColumnsTable.java:794)
at org.knime.core.data.container.RearrangeColumnsTable$ConcurrentNewColCalculator.compute(RearrangeColumnsTable.java:1)
at org.knime.core.util.MultiThreadWorker$ComputationTask$1.call(MultiThreadWorker.java:442)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:367)
at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:221)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)

Hey @Ashok121

thanks for posting the KNIME Log! Could you try to uninstall the KNIME Text processing Extension and reinstall it or use a fresh installation of KNIME?

Best regards
Lars

Hi @laaaarsi
I uninstalled Knime twice still showing same issue.
is there any way apart from uninstalling

Could you check if this file exist in your KNIME installation?

yourInstallationFolder\plugins\org.knime.ext.textprocessing.models_5.0.0.v202301131100\opennlpmodels\tokenize\en-token.nbin

Version number of the plugin can differ

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.