### Initialize RapidMiner Framework Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Required setup before using any RapidMiner functionality. Must define the home directory and execution mode. ```java import com.rapidminer.RapidMiner; import com.rapidminer.tools.PlatformUtilities; import java.nio.file.Paths; public class RapidMinerInit { public static void main(String[] args) { // Set the RapidMiner home directory System.setProperty(PlatformUtilities.PROPERTY_RAPIDMINER_HOME, Paths.get("").toAbsolutePath().toString()); // Set execution mode for command-line usage RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE); // Initialize RapidMiner with default settings RapidMiner.init(); // Check if initialization succeeded if (RapidMiner.isInitialized()) { System.out.println("RapidMiner " + RapidMiner.getLongVersion() + " initialized successfully"); } } } ``` -------------------------------- ### Launch RapidMiner Studio Core GUI Source: https://github.com/rapidminer/rapidminer-studio-modular/blob/master/rapidminer-studio-core/README.md Start the graphical user interface of RapidMiner Studio Core by creating a GuiLauncher.java file and running it. Ensure the Java class path includes all required jars and dependencies. ```java import com.rapidminer.gui.RapidMinerGUI; class GuiLauncher { public static void main(String args[]) throws Exception { System.setProperty(PlatformUtilities.PROPERTY_RAPIDMINER_HOME, Paths.get("").toAbsolutePath().toString()); RapidMinerGUI.registerStartupListener(new ToolbarGUIStartupListener()); RapidMinerGUI.main(args); } } ``` -------------------------------- ### Symmetric and Streaming Encryption with EncryptionProvider Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Demonstrates symmetric encryption for strings and streaming encryption for files. Initializes the encryption provider and shows usage with default and custom contexts, including encryption with associated data. Also includes an example of a non-encrypting provider for testing. ```java import com.rapidminer.tools.encryption.EncryptionProvider; import com.rapidminer.tools.encryption.EncryptionProviderBuilder; import com.rapidminer.tools.encryption.EncryptionProviderSymmetric; import com.rapidminer.tools.encryption.EncryptionProviderStreaming; import com.rapidminer.tools.encryption.exceptions.EncryptionException; import java.io.*; import java.nio.charset.StandardCharsets; public class EncryptionExample { public static void main(String[] args) throws EncryptionException, IOException { // Initialize encryption (usually done by RapidMiner.init()) EncryptionProvider.initialize(); // Create symmetric encryption provider with default context EncryptionProviderSymmetric symmetricProvider = new EncryptionProviderBuilder() .buildSymmetricProvider(); // Encrypt a string (e.g., password) String sensitiveData = "my_secret_password"; byte[] encrypted = symmetricProvider.encryptString(sensitiveData.toCharArray()); System.out.println("Encrypted length: " + encrypted.length + " bytes"); // Decrypt back to string char[] decrypted = symmetricProvider.decryptString(encrypted); System.out.println("Decrypted: " + new String(decrypted)); // Use custom encryption context EncryptionProviderSymmetric customProvider = new EncryptionProviderBuilder() .withContext("my-custom-context") .buildSymmetricProvider(); // Encrypt with associated data for additional security byte[] associatedData = "RapidMiner".getBytes(StandardCharsets.UTF_8); byte[] encryptedWithAD = symmetricProvider.encryptString( sensitiveData.toCharArray(), associatedData); char[] decryptedWithAD = symmetricProvider.decryptString(encryptedWithAD, associatedData); // Create provider that doesn't encrypt (for testing/development) EncryptionProviderSymmetric noEncryption = new EncryptionProviderBuilder() .withContext(null) .buildSymmetricProvider(); // Streaming encryption for large files EncryptionProviderStreaming streamingProvider = new EncryptionProviderBuilder() .buildStreamingProvider(); // Encrypt a file stream try (InputStream input = new FileInputStream("large_file.dat"); OutputStream output = new FileOutputStream("large_file.enc")) { InputStream encryptedStream = streamingProvider.encryptStream(input); encryptedStream.transferTo(output); } } } ``` -------------------------------- ### Configure Process Context and Lifecycle Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Demonstrates how to set repository locations, define macros, and attach state listeners to a RapidMiner process. ```java import com.rapidminer.Process; import com.rapidminer.ProcessContext; import com.rapidminer.ProcessStateListener; import com.rapidminer.operator.IOContainer; import com.rapidminer.tools.container.Pair; import java.util.List; public class ProcessContextExample { public static void main(String[] args) throws Exception { Process process = new Process(); // Configure process context ProcessContext context = process.getContext(); // Set input repository locations context.setInputRepositoryLocations(List.of( "//LocalRepository/data/training_data", "//LocalRepository/data/test_data" )); // Set output repository locations context.setOutputRepositoryLocations(List.of( "//LocalRepository/results/model", "//LocalRepository/results/performance" )); // Set context macros context.setMacros(List.of( new Pair<>("run_date", "2024-01-15"), new Pair<>("experiment_name", "baseline_v1") )); // Add process state listener process.addProcessStateListener(new ProcessStateListener() { @Override public void started(Process process) { System.out.println("Process started"); } @Override public void paused(Process process) { System.out.println("Process paused"); } @Override public void resumed(Process process) { System.out.println("Process resumed"); } @Override public void stopped(Process process) { System.out.println("Process stopped"); } }); // Run with state management try { IOContainer result = process.run(); System.out.println("Process state: " + process.getProcessState()); } catch (Exception e) { // Stop process on error process.stop(); } // Programmatic pause/resume // process.pause(); // process.resume(); } } ``` -------------------------------- ### Accessing File System and Platform Utilities in Java Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Demonstrates retrieving RapidMiner directory paths, ensuring home directory configuration, and querying operating system and memory details. ```java import com.rapidminer.tools.FileSystemService; import com.rapidminer.tools.PlatformUtilities; import com.rapidminer.tools.SystemInfoUtilities; import java.io.File; public class FileSystemExample { public static void main(String[] args) { // Get RapidMiner user directory (~/.RapidMiner) File userDir = FileSystemService.getUserRapidMinerDir(); System.out.println("User directory: " + userDir.getAbsolutePath()); // Get standard working directory String workDir = FileSystemService.getStandardWorkingDir(); System.out.println("Working directory: " + workDir); // Get log file location File logFile = FileSystemService.getLogFile(); System.out.println("Log file: " + logFile.getAbsolutePath()); // Ensure RapidMiner home is set PlatformUtilities.ensureRapidMinerHomeSet(true); String home = System.getProperty(PlatformUtilities.PROPERTY_RAPIDMINER_HOME); System.out.println("RapidMiner home: " + home); // Get system information SystemInfoUtilities.OperatingSystem os = SystemInfoUtilities.getOperatingSystem(); System.out.println("Operating System: " + os); long availableMemory = SystemInfoUtilities.getAvailablePhysicalMemorySize(); System.out.println("Available memory: " + (availableMemory / 1024 / 1024) + " MB"); } } ``` -------------------------------- ### Create and Execute Data Mining Processes Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Demonstrates loading a process from a file or XML string and executing it using the Process class. ```java import com.rapidminer.Process; import com.rapidminer.operator.IOContainer; import com.rapidminer.operator.OperatorException; import com.rapidminer.tools.XMLException; import java.io.File; import java.io.IOException; public class ProcessExecution { public static void main(String[] args) throws IOException, XMLException, OperatorException { // Initialize RapidMiner first (see initialization example) RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE); RapidMiner.init(); // Load process from file File processFile = new File("my_process.rmp"); Process process = new Process(processFile); // Or create from XML string String processXml = """ """; Process xmlProcess = new Process(processXml, Process.NO_ENCRYPTION); // Execute the process IOContainer result = process.run(); // Process results System.out.println("Process completed with " + result.getIOObjects().length + " result(s)"); } } ``` -------------------------------- ### Create and Connect Operators in a Process Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Demonstrates how to create operators, set their parameters, add them to a process, and connect their ports programmatically. Requires importing necessary RapidMiner classes. ```java import com.rapidminer.Process; import com.rapidminer.operator.Operator; import com.rapidminer.operator.OperatorCreationException; import com.rapidminer.operator.ProcessRootOperator; import com.rapidminer.operator.ports.OutputPort; import com.rapidminer.tools.OperatorService; public class OperatorExample { public static void main(String[] args) throws OperatorCreationException { // Create a new empty process Process process = new Process(); ProcessRootOperator root = process.getRootOperator(); // Create operators using OperatorService Operator readCsv = OperatorService.createOperator("read_csv"); readCsv.setParameter("csv_file", "/data/mydata.csv"); readCsv.setParameter("column_separators", ";"); // Create a decision tree learner Operator decisionTree = OperatorService.createOperator("decision_tree"); decisionTree.setParameter("criterion", "gain_ratio"); decisionTree.setParameter("maximal_depth", "10"); // Add operators to the process root.getSubprocess(0).addOperator(readCsv); root.getSubprocess(0).addOperator(decisionTree); // Connect operators via ports OutputPort csvOutput = readCsv.getOutputPorts().getPortByName("output"); csvOutput.connectTo(decisionTree.getInputPorts().getPortByName("training set")); // Connect to process output decisionTree.getOutputPorts().getPortByName("model") .connectTo(root.getSubprocess(0).getInnerSinks().getPortByIndex(0)); // Get all operators in process for (Operator op : process.getAllOperators()) { System.out.println("Operator: " + op.getName() + " (" + op.getOperatorDescription().getKey() + ")"); } } } ``` -------------------------------- ### Perform Global Search Operations in Java Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Demonstrates how to execute basic and advanced searches, handle result documents, retrieve highlights, manage pagination, and list available search categories. ```java import com.rapidminer.search.*; import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.document.Document; import java.util.List; public class GlobalSearchExample { public static void main(String[] args) throws ParseException { // Search with default settings GlobalSearchResult result = new GlobalSearchResultBuilder("decision tree") .runSearch(); System.out.println("Found " + result.getTotalNumberOfResults() + " results"); // Process search results List documents = result.getResultDocuments(); for (Document doc : documents) { String name = doc.get(GlobalSearchUtilities.FIELD_NAME); String category = doc.get(GlobalSearchUtilities.FIELD_CATEGORY); System.out.println(" - " + name + " (" + category + ")"); } // Advanced search with options GlobalSearchResult advancedResult = new GlobalSearchResultBuilder("k-means cluster*") .setMaxNumberOfResults(50) .setHighlightResult(true) .setSimpleMode(true) // Auto-add wildcards for user-friendly search .runSearch(); // Get highlighted fragments for result display List highlights = advancedResult.getBestFragments(); for (int i = 0; i < advancedResult.getResultDocuments().size(); i++) { String[] fragments = highlights.get(i); if (fragments != null && fragments.length > 0) { System.out.println("Match highlight: " + String.join(" ... ", fragments)); } } // Pagination using search offset GlobalSearchResult firstPage = new GlobalSearchResultBuilder("operator") .setMaxNumberOfResults(10) .runSearch(); // Get next page using last result as offset if (firstPage.getLastResult() != null) { GlobalSearchResult secondPage = new GlobalSearchResultBuilder("operator") .setMaxNumberOfResults(10) .setSearchOffset(firstPage.getLastResult()) .runSearch(); } // Search within specific categories List allCategories = GlobalSearchRegistry.INSTANCE.getAllSearchCategories(); for (GlobalSearchCategory category : allCategories) { System.out.println("Available category: " + category.getCategoryId()); } } } ``` -------------------------------- ### Run RapidMiner Studio Core in CLI Mode Source: https://github.com/rapidminer/rapidminer-studio-modular/blob/master/rapidminer-studio-core/README.md Execute RapidMiner Studio in command-line mode by creating a CliLauncher.java file. This requires the EULA to be accepted at least once in GUI mode. ```java import com.rapidminer.RapidMiner; class CliLauncher { public static void main(String args[]) throws Exception { System.setProperty(PlatformUtilities.PROPERTY_RAPIDMINER_HOME, Paths.get("").toAbsolutePath().toString()); RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE); RapidMiner.init(); } } ``` -------------------------------- ### Implement Logging Service Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Shows how to utilize the RapidMiner LogService for hierarchical logging, setting verbosity levels, and structured parameter logging. ```java import com.rapidminer.tools.LogService; import com.rapidminer.tools.LoggingHandler; import java.util.logging.Level; import java.util.logging.Logger; public class LoggingExample { public static void main(String[] args) { // Get the root logger Logger rootLogger = LogService.getRoot(); // Log messages at different levels rootLogger.info("Process execution started"); rootLogger.fine("Loading operator configuration"); rootLogger.config("Using default parameters"); rootLogger.warning("Memory usage is high"); rootLogger.severe("Critical error occurred"); // Set log level rootLogger.setLevel(Level.FINE); // Use with Process logger Process process = new Process(); Logger processLogger = process.getLogger(); processLogger.info("Starting custom process"); // Structured logging with parameters processLogger.log(Level.INFO, "Processing {0} records in batch {1}", new Object[]{1000, 5}); // Log with exception try { // some operation } catch (Exception e) { rootLogger.log(Level.SEVERE, "Operation failed", e); } } } ``` -------------------------------- ### Handle Macros in a RapidMiner Process Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Shows how to set and retrieve macro values for parameterizing a RapidMiner process. Macros can be added directly or passed during the process run. Ensure necessary imports are present. ```java import com.rapidminer.Process; import com.rapidminer.MacroHandler; import com.rapidminer.operator.IOContainer; import java.util.HashMap; import java.util.Map; public class MacroExample { public static void runProcessWithMacros() throws Exception { Process process = new Process(new File("parameterized_process.rmp")); // Access the macro handler MacroHandler macroHandler = process.getMacroHandler(); // Set macros before running macroHandler.addMacro("input_file", "/data/training.csv"); macroHandler.addMacro("output_dir", "/results/"); macroHandler.addMacro("model_name", "my_model_v1"); // Alternative: pass macros via run method Map macros = new HashMap<>(); macros.put("threshold", "0.5"); macros.put("iterations", "100"); IOContainer result = process.run(new IOContainer(), LogService.OFF, macros); // Retrieve macro value (e.g., set by process operators) String resultMacro = macroHandler.getMacro("result_accuracy"); System.out.println("Result accuracy: " + resultMacro); // Clear all macros process.clearMacros(); } } ``` -------------------------------- ### Internationalization (I18N) for Localized Messages Source: https://context7.com/rapidminer/rapidminer-studio-modular/llms.txt Shows how to retrieve localized messages for GUI elements, errors, and settings using the I18N utility. Demonstrates parameter substitution, handling missing keys, and direct access to resource bundles, including registering custom bundles. ```java import com.rapidminer.tools.I18N; import com.rapidminer.tools.I18N.SettingsType; import java.util.ResourceBundle; public class I18NExample { public static void main(String[] args) { // Get localized GUI message String label = I18N.getGUIMessage("gui.dialog.confirm.title"); System.out.println("Confirm dialog title: " + label); // Get message with parameters (using MessageFormat syntax) String errorMsg = I18N.getErrorMessage("error.file_not_found", "/path/to/file.csv"); System.out.println("Error: " + errorMsg); // Get user error message (for operator errors) String userError = I18N.getUserErrorMessage("error.operator.invalid_parameter", "decision_tree", "maximal_depth"); // Get settings message with type suffix String settingTitle = I18N.getSettingsMessage("rapidminer.general.timezone", SettingsType.TITLE); String settingDesc = I18N.getSettingsMessage("rapidminer.general.timezone", SettingsType.DESCRIPTION); // Get message or null if not found (avoids returning the key) String maybeNull = I18N.getGUIMessageOrNull("gui.unknown.key"); if (maybeNull == null) { System.out.println("Key not found in resource bundle"); } // Get GUI label shortcut String buttonLabel = I18N.getGUILabel("ok_button"); // Looks up "gui.label.ok_button" // Access resource bundles directly ResourceBundle guiBundle = I18N.getGUIBundle(); ResourceBundle errorBundle = I18N.getErrorBundle(); ResourceBundle settingsBundle = I18N.getSettingsBundle(); // Register custom resource bundle for extensions ResourceBundle customBundle = ResourceBundle.getBundle( "com.mycompany.extension.i18n.Messages"); I18N.registerGUIBundle(customBundle); I18N.registerErrorBundle(customBundle); } } ``` -------------------------------- ### Add RapidMiner Studio Core Dependency with Maven Source: https://github.com/rapidminer/rapidminer-studio-modular/blob/master/rapidminer-studio-core/README.md Integrate the RapidMiner Studio Core library into your project by configuring the repository and dependency in your Maven pom.xml file. ```xml ... rapidminer https://maven.rapidminer.com/content/groups/public/ ... com.rapidminer.studio rapidminer-studio-core LATEST ... ``` -------------------------------- ### Add RapidMiner Studio Core Dependency with Gradle Source: https://github.com/rapidminer/rapidminer-studio-modular/blob/master/rapidminer-studio-core/README.md Include the RapidMiner Studio Core library in your project by adding the specified repository and dependency to your Gradle build file. ```gradle apply plugin: 'java' repositories { maven { url 'https://maven.rapidminer.com/content/groups/public/' } } dependencies { compile group: 'com.rapidminer.studio', name: 'rapidminer-studio-core', version: '+' } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.