The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
ways to get the k-means inertia
Was looking for some way to get the k-means inertia so I can get the 'best' value, but it seems to be not very straightforward to do within rapidminer. Anybody who tried something similar or has better solutions to get the optimal k value?
Tagged:
0
Best Answer
-
lionelderkrikor RapidMiner Certified Analyst, Member Posts: 1,195 UnicornHi @kayman ,
You can try to use an Optimization Loop to obtain the curve Average within centroid distance according to the k.
Then, you can plot this curve in RapidmMiner and determine the optimal value for the number of cluster(s) k.
Here an example of such curve applied to the Iris dataset :
According to this curve, we can conclude that the optimal value for k for this dataset is between 3 and 5 included...
The process :<?xml version="1.0" encoding="UTF-8"?><process version="9.4.000-BETA"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="9.4.000-BETA" 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="9.4.000-BETA" expanded="true" height="68" name="Retrieve Iris" width="90" x="45" y="85"> <parameter key="repository_entry" value="//Samples/data/Iris"/> </operator> <operator activated="true" class="normalize" compatibility="9.4.000-BETA" expanded="true" height="103" name="Normalize" width="90" x="246" y="85"> <parameter key="return_preprocessing_model" value="false"/> <parameter key="create_view" value="false"/> <parameter key="attribute_filter_type" value="all"/> <parameter key="attribute" value=""/> <parameter key="attributes" value=""/> <parameter key="use_except_expression" value="false"/> <parameter key="value_type" value="numeric"/> <parameter key="use_value_type_exception" value="false"/> <parameter key="except_value_type" value="real"/> <parameter key="block_type" value="value_series"/> <parameter key="use_block_type_exception" value="false"/> <parameter key="except_block_type" value="value_series_end"/> <parameter key="invert_selection" value="false"/> <parameter key="include_special_attributes" value="false"/> <parameter key="method" value="Z-transformation"/> <parameter key="min" value="0.0"/> <parameter key="max" value="1.0"/> <parameter key="allow_negative_values" value="false"/> </operator> <operator activated="true" class="concurrency:optimize_parameters_grid" compatibility="9.4.000-BETA" expanded="true" height="145" name="Optimize Parameters (Grid)" width="90" x="447" y="85"> <list key="parameters"> <parameter key="Clustering.k" value="[2.0;15;15;linear]"/> </list> <parameter key="error_handling" value="fail on error"/> <parameter key="log_performance" value="true"/> <parameter key="log_all_criteria" value="false"/> <parameter key="synchronize" value="false"/> <parameter key="enable_parallel_execution" value="true"/> <process expanded="true"> <operator activated="true" class="concurrency:k_means" compatibility="9.4.000-BETA" expanded="true" height="82" name="Clustering" width="90" x="246" y="34"> <parameter key="add_cluster_attribute" value="true"/> <parameter key="add_as_label" value="false"/> <parameter key="remove_unlabeled" value="false"/> <parameter key="k" value="5"/> <parameter key="max_runs" value="10"/> <parameter key="determine_good_start_values" value="true"/> <parameter key="measure_types" value="BregmanDivergences"/> <parameter key="mixed_measure" value="MixedEuclideanDistance"/> <parameter key="nominal_measure" value="NominalDistance"/> <parameter key="numerical_measure" value="EuclideanDistance"/> <parameter key="divergence" value="SquaredEuclideanDistance"/> <parameter key="kernel_type" value="radial"/> <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_degree" value="3.0"/> <parameter key="kernel_shift" value="1.0"/> <parameter key="kernel_a" value="1.0"/> <parameter key="kernel_b" value="0.0"/> <parameter key="max_optimization_steps" value="100"/> <parameter key="use_local_random_seed" value="false"/> <parameter key="local_random_seed" value="1992"/> </operator> <operator activated="true" class="cluster_distance_performance" compatibility="9.4.000-BETA" expanded="true" height="103" name="Performance" width="90" x="380" y="34"> <parameter key="main_criterion" value="Avg. within centroid distance"/> <parameter key="main_criterion_only" value="false"/> <parameter key="normalize" value="false"/> <parameter key="maximize" value="false"/> </operator> <connect from_port="input 1" to_op="Clustering" to_port="example set"/> <connect from_op="Clustering" from_port="cluster model" to_op="Performance" to_port="cluster model"/> <connect from_op="Clustering" from_port="clustered set" to_op="Performance" to_port="example set"/> <connect from_op="Performance" from_port="performance" to_port="performance"/> <connect from_op="Performance" from_port="example set" to_port="output 1"/> <connect from_op="Performance" from_port="cluster model" to_port="model"/> <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"/> <portSpacing port="sink_output 2" spacing="0"/> </process> </operator> <connect from_op="Retrieve Iris" from_port="output" to_op="Normalize" to_port="example set input"/> <connect from_op="Normalize" from_port="example set output" to_op="Optimize Parameters (Grid)" to_port="input 1"/> <connect from_op="Optimize Parameters (Grid)" from_port="performance" to_port="result 1"/> <connect from_op="Optimize Parameters (Grid)" from_port="model" to_port="result 2"/> <connect from_op="Optimize Parameters (Grid)" from_port="parameter set" to_port="result 3"/> <connect from_op="Optimize Parameters (Grid)" from_port="output 1" to_port="result 4"/> <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"/> <portSpacing port="sink_result 5" spacing="0"/> </process> </operator> </process>
Hope this helps,
Regards,
Lionel8
Answers