Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

Logging Best Parameters and Learned Weights from Cross Validation

IUH_86IUH_86 Member Posts: 4 Learner I
edited May 2023 in Help
Hi!
Is there a way to obtain the best parameter combination output from cross-validation operator? After running the cross validation on the train set, I need to log the best parameters and the weights for the features learned by the model. What operators should I use for this? 

Answers

  • ceaperezceaperez Member Posts: 541 Unicorn
    Hi @IUH_86

    have you try to connect the mod port to the res port from the Cross Validation operator?

    There you have acess to the final model. 

    Best,

    Cesar
  • IUH_86IUH_86 Member Posts: 4 Learner I
    Hi @ceaperez,

    Thanks for the helpful answer. But I am doing this iteratively, so I must log the feature weights and model parameters at each iteration. I cannot find a suitable option in the log operator to do this.
  • ceaperezceaperez Member Posts: 541 Unicorn
    Hi @IUH_86

    are you trying with log operator?

    Best, 

    Cesar 
  • IUH_86IUH_86 Member Posts: 4 Learner I
    Hi @ceaperez,

    Yes, I am trying the log operator. But I cannot figure out the parameter options in the log operator to retrieve the best model parameters and feature weights from cross-validation. Do you have any idea how to do it?
  • ceaperezceaperez Member Posts: 541 Unicorn
    Hi @IUH_86,

    can you share your process file ? 

    Cheers
  • IUH_86IUH_86 Member Posts: 4 Learner I
    Hi @ceaperez,

    Below is the process file. I must get weights for each attribute as columns for each window in the log file. 

    <?xml version="1.0" encoding="UTF-8"?><process version="10.1.002">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="10.1.002" expanded="true" name="Process">
    <parameter key="logverbosity" value="init"/>
    <parameter key="random_seed" value="2001"/>
    <parameter key="send_mail" value="never"/>
    <parameter key="notification_email" value=""/>
    <parameter key="process_duration_for_mail" value="30"/>
    <parameter key="encoding" value="SYSTEM"/>
    <process expanded="true">
    <operator activated="true" class="retrieve" compatibility="10.1.002" expanded="true" height="68" name="Retrieve Weighting" width="90" x="45" y="34">
    <parameter key="repository_entry" value="//Samples/data/Weighting"/>
    </operator>
    <operator activated="true" class="filter_example_range" compatibility="10.1.002" expanded="true" height="82" name="Filter Example Range" width="90" x="179" y="34">
    <parameter key="first_example" value="1"/>
    <parameter key="last_example" value="302"/>
    <parameter key="invert_filter" value="false"/>
    </operator>
    <operator activated="true" class="blending:set_role" compatibility="10.1.002" expanded="true" height="82" name="Set Role" width="90" x="313" y="34">
    <list key="set_roles">
    <parameter key="weighting.dat (7)" value="label"/>
    </list>
    </operator>
    <operator activated="true" class="time_series:sliding_window_validation" compatibility="10.1.000" expanded="true" height="145" name="Sliding Window Validation" width="90" x="447" y="34">
    <parameter key="has_indices" value="false"/>
    <parameter key="indices_attribute" value="Last Date in window"/>
    <parameter key="sort_time_series" value="false"/>
    <parameter key="expert_settings" value="false"/>
    <parameter key="unit" value="example based"/>
    <parameter key="windows_defined" value="from start"/>
    <parameter key="custom_start_point" value="5"/>
    <parameter key="custom_end_point" value="100"/>
    <parameter key="training_window_size" value="200"/>
    <parameter key="custom_start_time" value="2000-01-01 00:00:00"/>
    <parameter key="custom_end_time" value="2030-01-01 00:00:00"/>
    <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>
    <parameter key="training_window_size_time" value="1.Hours"/>
    <parameter key="windows_stop_definition" value="from next window start"/>
    <parameter key="training_window_start_attribute" value=""/>
    <parameter key="training_window_stop_attribute" value=""/>
    <parameter key="no_overlapping_windows" value="false"/>
    <parameter key="step_size" value="1"/>
    <parameter key="step_size_time" value="1.Minutes"/>
    <parameter key="test_window_size" value="100"/>
    <parameter key="test_window_size_time" value="1.Hours"/>
    <parameter key="test_window_start_attribute" value=""/>
    <parameter key="test_window_stop_attribute" value=""/>
    <parameter key="empty_window_handling" value="add empty exampleset"/>
    <parameter key="enable_parallel_execution" value="true"/>
    <process expanded="true">
    <operator activated="true" class="concurrency:optimize_parameters_grid" compatibility="10.1.002" expanded="true" height="124" name="Optimize Parameters (Grid)" width="90" x="112" y="34">
    <list key="parameters">
    <parameter key="SVM.kernel_type" value="dot,radial,polynomial"/>
    </list>
    <parameter key="error_handling" value="fail on error"/>
    <parameter key="log_performance" value="true"/>
    <parameter key="log_all_criteria" value="true"/>
    <parameter key="synchronize" value="false"/>
    <parameter key="enable_parallel_execution" value="true"/>
    <process expanded="true">
    <operator activated="true" class="concurrency:cross_validation" compatibility="10.1.002" expanded="true" height="145" name="Cross Validation" width="90" x="246" y="34">
    <parameter key="split_on_batch_attribute" value="false"/>
    <parameter key="leave_one_out" value="false"/>
    <parameter key="number_of_folds" value="5"/>
    <parameter key="sampling_type" value="linear sampling"/>
    <parameter key="use_local_random_seed" value="false"/>
    <parameter key="local_random_seed" value="1992"/>
    <parameter key="enable_parallel_execution" value="true"/>
    <process expanded="true">
    <operator activated="true" class="support_vector_machine" compatibility="10.1.002" expanded="true" height="124" name="SVM" width="90" x="179" y="34">
    <parameter key="kernel_type" value="dot"/>
    <parameter key="kernel_gamma" value="1.0"/>
    <parameter key="kernel_sigma1" value="1.0"/>
    <parameter key="kernel_sigma2" value="0.0"/>
    <parameter key="kernel_sigma3" value="2.0"/>
    <parameter key="kernel_shift" value="1.0"/>
    <parameter key="kernel_degree" value="2.0"/>
    <parameter key="kernel_a" value="1.0"/>
    <parameter key="kernel_b" value="0.0"/>
    <parameter key="kernel_cache" value="200"/>
    <parameter key="C" value="0.0"/>
    <parameter key="convergence_epsilon" value="0.001"/>
    <parameter key="max_iterations" value="100000"/>
    <parameter key="scale" value="true"/>
    <parameter key="calculate_weights" value="true"/>
    <parameter key="return_optimization_performance" value="true"/>
    <parameter key="L_pos" value="1.0"/>
    <parameter key="L_neg" value="1.0"/>
    <parameter key="epsilon" value="0.0"/>
    <parameter key="epsilon_plus" value="0.0"/>
    <parameter key="epsilon_minus" value="0.0"/>
    <parameter key="balance_cost" value="false"/>
    <parameter key="quadratic_loss_pos" value="false"/>
    <parameter key="quadratic_loss_neg" value="false"/>
    <parameter key="estimate_performance" value="false"/>
    </operator>
    <connect from_port="training set" to_op="SVM" to_port="training set"/>
    <connect from_op="SVM" from_port="model" to_port="model"/>
    <connect from_op="SVM" from_port="estimated performance" to_port="through 1"/>
    <connect from_op="SVM" from_port="weights" to_port="through 2"/>
    <portSpacing port="source_training set" spacing="0"/>
    <portSpacing port="sink_model" spacing="0"/>
    <portSpacing port="sink_through 1" spacing="0"/>
    <portSpacing port="sink_through 2" spacing="0"/>
    <portSpacing port="sink_through 3" spacing="0"/>
    </process>
    <process expanded="true">
    <operator activated="true" class="apply_model" compatibility="10.1.002" expanded="true" height="82" name="Apply Model (2)" width="90" x="112" y="34">
    <list key="application_parameters"/>
    </operator>
    <operator activated="true" class="performance_classification" compatibility="10.1.002" expanded="true" height="82" name="Performance (2)" width="90" x="277" y="34">
    <parameter key="main_criterion" value="root_mean_squared_error"/>
    <parameter key="accuracy" value="true"/>
    <parameter key="classification_error" value="false"/>
    <parameter key="kappa" value="false"/>
    <parameter key="weighted_mean_recall" value="false"/>
    <parameter key="weighted_mean_precision" value="false"/>
    <parameter key="spearman_rho" value="false"/>
    <parameter key="kendall_tau" value="false"/>
    <parameter key="absolute_error" value="false"/>
    <parameter key="relative_error" value="false"/>
    <parameter key="relative_error_lenient" value="false"/>
    <parameter key="relative_error_strict" value="false"/>
    <parameter key="normalized_absolute_error" value="false"/>
    <parameter key="root_mean_squared_error" value="true"/>
    <parameter key="root_relative_squared_error" value="false"/>
    <parameter key="squared_error" value="false"/>
    <parameter key="correlation" value="false"/>
    <parameter key="squared_correlation" value="false"/>
    <parameter key="cross-entropy" value="false"/>
    <parameter key="margin" value="false"/>
    <parameter key="soft_margin_loss" value="false"/>
    <parameter key="logistic_loss" value="false"/>
    <parameter key="skip_undefined_labels" value="true"/>
    <parameter key="use_example_weights" value="true"/>
    <list key="class_weights"/>
    </operator>
    <connect from_port="model" to_op="Apply Model (2)" to_port="model"/>
    <connect from_port="test set" to_op="Apply Model (2)" to_port="unlabelled data"/>
    <connect from_op="Apply Model (2)" from_port="labelled data" to_op="Performance (2)" to_port="labelled data"/>
    <connect from_op="Performance (2)" from_port="performance" to_port="performance 1"/>
    <connect from_op="Performance (2)" from_port="example set" to_port="test set results"/>
    <portSpacing port="source_model" spacing="0"/>
    <portSpacing port="source_test set" spacing="0"/>
    <portSpacing port="source_through 1" spacing="0"/>
    <portSpacing port="source_through 2" spacing="0"/>
    <portSpacing port="source_through 3" spacing="0"/>
    <portSpacing port="sink_test set results" spacing="0"/>
    <portSpacing port="sink_performance 1" spacing="0"/>
    <portSpacing port="sink_performance 2" spacing="0"/>
    </process>
    </operator>
    <connect from_port="input 1" to_op="Cross Validation" to_port="example set"/>
    <connect from_op="Cross Validation" from_port="model" to_port="model"/>
    <connect from_op="Cross Validation" from_port="performance 1" to_port="performance"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="source_input 2" spacing="0"/>
    <portSpacing port="sink_performance" spacing="0"/>
    <portSpacing port="sink_model" spacing="0"/>
    <portSpacing port="sink_output 1" spacing="0"/>
    </process>
    </operator>
    <connect from_port="training set" to_op="Optimize Parameters (Grid)" to_port="input 1"/>
    <connect from_op="Optimize Parameters (Grid)" from_port="model" to_port="model"/>
    <connect from_op="Optimize Parameters (Grid)" from_port="parameter set" to_port="through 1"/>
    <portSpacing port="source_training set" spacing="0"/>
    <portSpacing port="sink_model" spacing="0"/>
    <portSpacing port="sink_through 1" spacing="0"/>
    <portSpacing port="sink_through 2" spacing="0"/>
    </process>
    <process expanded="true">
    <operator activated="true" class="apply_model" compatibility="10.1.002" expanded="true" height="82" name="Apply Model" width="90" x="112" y="34">
    <list key="application_parameters"/>
    </operator>
    <operator activated="true" class="performance_classification" compatibility="10.1.002" expanded="true" height="82" name="Performance" width="90" x="246" y="34">
    <parameter key="main_criterion" value="root_mean_squared_error"/>
    <parameter key="accuracy" value="true"/>
    <parameter key="classification_error" value="false"/>
    <parameter key="kappa" value="false"/>
    <parameter key="weighted_mean_recall" value="false"/>
    <parameter key="weighted_mean_precision" value="false"/>
    <parameter key="spearman_rho" value="false"/>
    <parameter key="kendall_tau" value="false"/>
    <parameter key="absolute_error" value="true"/>
    <parameter key="relative_error" value="true"/>
    <parameter key="relative_error_lenient" value="false"/>
    <parameter key="relative_error_strict" value="false"/>
    <parameter key="normalized_absolute_error" value="false"/>
    <parameter key="root_mean_squared_error" value="true"/>
    <parameter key="root_relative_squared_error" value="false"/>
    <parameter key="squared_error" value="false"/>
    <parameter key="correlation" value="false"/>
    <parameter key="squared_correlation" value="false"/>
    <parameter key="cross-entropy" value="false"/>
    <parameter key="margin" value="false"/>
    <parameter key="soft_margin_loss" value="false"/>
    <parameter key="logistic_loss" value="false"/>
    <parameter key="skip_undefined_labels" value="true"/>
    <parameter key="use_example_weights" value="true"/>
    <list key="class_weights"/>
    </operator>
    <operator activated="true" class="log" compatibility="10.1.002" expanded="true" height="82" name="Log" width="90" x="112" y="238">
    <list key="log">
    <parameter key="SVM.kernel" value="operator.SVM.parameter.kernel_type"/>
    <parameter key="Window Number" value="operator.Sliding Window Validation.value.looptime"/>
    <parameter key="Performance" value="operator.Performance.value.accuracy"/>
    </list>
    <parameter key="sorting_type" value="none"/>
    <parameter key="sorting_k" value="100"/>
    <parameter key="persistent" value="false"/>
    </operator>
    <connect from_port="test set" to_op="Apply Model" to_port="unlabelled data"/>
    <connect from_port="model" to_op="Apply Model" to_port="model"/>
    <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
    <connect from_op="Performance" from_port="performance" to_port="performance 1"/>
    <connect from_op="Performance" from_port="example set" to_port="test set results"/>
    <portSpacing port="source_test set" spacing="0"/>
    <portSpacing port="source_model" spacing="0"/>
    <portSpacing port="source_through 1" spacing="0"/>
    <portSpacing port="source_through 2" spacing="0"/>
    <portSpacing port="sink_test set results" spacing="0"/>
    <portSpacing port="sink_performance 1" spacing="0"/>
    <portSpacing port="sink_performance 2" spacing="0"/>
    <description align="center" color="yellow" colored="false" height="69" resized="false" width="126" x="72" y="125">Apply the best model on the test dataset</description>
    <description align="center" color="yellow" colored="false" height="93" resized="false" width="144" x="229" y="124">Collect performance measures for the current test set and the forecasted values</description>
    </process>
    </operator>
    <connect from_op="Retrieve Weighting" from_port="output" to_op="Filter Example Range" to_port="example set input"/>
    <connect from_op="Filter Example Range" from_port="example set output" to_op="Set Role" to_port="example set input"/>
    <connect from_op="Set Role" from_port="example set output" to_op="Sliding Window Validation" to_port="example set"/>
    <connect from_op="Sliding Window Validation" from_port="model" to_port="result 1"/>
    <connect from_op="Sliding Window Validation" from_port="test result set" to_port="result 2"/>
    <connect from_op="Sliding Window Validation" from_port="performance 1" to_port="result 3"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    <portSpacing port="sink_result 3" spacing="0"/>
    <portSpacing port="sink_result 4" spacing="0"/>
    </process>
    </operator>
    </process>
Sign In or Register to comment.