Assigning class based on multiple attributes

b00122599
b00122599 New Altair Community Member
edited 2024 05 in Community Q&A
Hey folks,

Sorry looking for help on how to start a problem. I have a CSV file with 15 attributes all of which are numeric with a range of 1-20 for each attribute. I want to create a classification based on which attribute is scored 20. Only one of the attributes per each record should be scored 20. I only want to have 4 classs for example Man, Woman, Boy, Girl, so if one of the first three atrributes is 20 then I want to classify it as a Man, if one of attributes four to six is 20 I want classifiy it as a woman. I hope this makes sense, any help is much appreciated.

Neil.
Tagged:

Best Answer

  • varunm1
    varunm1 New Altair Community Member
    edited 2019 03 Answer ✓
    Hi Neil, @b00122599

    So you are trying to create a new column with one of the four classes based on a value in attributes. If this is what you are trying to do,  You can use "generate attribute" operator with expression using IF statement and write nested if functions. If you can inform you attribute names and conditions like which attributes should be compared for Man etc. we can help. Sample Nested If statement which might be useful is below. Please correct me if my understanding is not correct. a1, a2 .. are attribute 1, 2 ...

    if (a1==20, "Man", if (a2==20, "Man", if (a3==20, "Man", if (a4==20, "Women", if (a5==20, "Women", if (a6==20, "Women", "Boy"))))))
    The above expression is IF a1 is 20 then "Man" else it will check a2, similarly all the nested statements until any condition is satisfied.

    Thanks

Answers

  • varunm1
    varunm1 New Altair Community Member
    edited 2019 03 Answer ✓
    Hi Neil, @b00122599

    So you are trying to create a new column with one of the four classes based on a value in attributes. If this is what you are trying to do,  You can use "generate attribute" operator with expression using IF statement and write nested if functions. If you can inform you attribute names and conditions like which attributes should be compared for Man etc. we can help. Sample Nested If statement which might be useful is below. Please correct me if my understanding is not correct. a1, a2 .. are attribute 1, 2 ...

    if (a1==20, "Man", if (a2==20, "Man", if (a3==20, "Man", if (a4==20, "Women", if (a5==20, "Women", if (a6==20, "Women", "Boy"))))))
    The above expression is IF a1 is 20 then "Man" else it will check a2, similarly all the nested statements until any condition is satisfied.

    Thanks
  • b00122599
    b00122599 New Altair Community Member
    Thanks Varun I will give this a go much appreciated!