¿How can I check if a string is contained in an nominal attribute?

YuzheYuzhe Member Posts: 1 Newbie
I'm doing de Titanic Competition of Kaggle and I trying to check if the attribute name has string like Mr, Mrs, Miss,...
But I don't know which operator is the adequate in this situacion.  

Answers

  • rjones13rjones13 Member Posts: 128 Unicorn
    Hi @Yuzhe,

    The approach you can take depends on whether you want to filter examples, or end up with some further calculations. For the former, you could use Filter Examples using the condition "contains", and also have multiple checks where an example only needs to match one. I've provided a short example of this below. You could also use Generate Attributes and the contains() function, which would give True/False depending on whether a nominal attribute contains the search string.

    Hope this helps.

    Best,

    Roland


    <?xml version="1.0" encoding="UTF-8"?><process version="10.3.000">
    
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="10.3.000" 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="UTF-8"/>
    <process expanded="true">
    <operator activated="true" class="retrieve" compatibility="10.3.000" expanded="true" height="68" name="Retrieve Titanic" width="90" x="45" y="34">
    <parameter key="repository_entry" value="//Samples/data/Titanic"/>
    </operator>
    <operator activated="true" class="filter_examples" compatibility="10.3.000" expanded="true" height="103" name="Filter Examples" width="90" x="179" y="34">
    <parameter key="parameter_expression" value=""/>
    <parameter key="condition_class" value="custom_filters"/>
    <parameter key="invert_filter" value="false"/>
    <list key="filters_list">
    <parameter key="filters_entry_key" value="Name.contains.Miss"/>
    <parameter key="filters_entry_key" value="Name.contains.Mrs"/>
    </list>
    <parameter key="filters_logic_and" value="false"/>
    <parameter key="filters_check_metadata" value="true"/>
    </operator>
    <connect from_op="Retrieve Titanic" from_port="output" to_op="Filter Examples" to_port="example set input"/>
    <connect from_op="Filter Examples" from_port="example set output" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>
Sign In or Register to comment.