The Siemens Community Catalyst program was co-created with our community to acknowledge technology leaders who consistently contribute to the Siemens Community. Nominations are accepted on a rolling basis.
mierswa wrote:Hello,nice idea but there is currently no operator for this, sorry.Cheers,Ingo
import java.util.List;import java.util.regex.Pattern;import java.util.regex.PatternSyntaxException;import com.rapidminer.example.Attribute;import com.rapidminer.example.AttributeWeights;import com.rapidminer.example.ExampleSet;import com.rapidminer.operator.OperatorDescription;import com.rapidminer.operator.OperatorException;import com.rapidminer.operator.features.weighting.AbstractWeighting;import com.rapidminer.parameter.ParameterType;import com.rapidminer.parameter.ParameterTypeDouble;import com.rapidminer.parameter.ParameterTypeList;public class AttributeWeighting extends AbstractWeighting { private static final String WEIGHTING_PARAMETER = "regex"; public AttributeWeighting(OperatorDescription description) { super(description); }@Override public AttributeWeights calculateWeights(ExampleSet exampleSet) throws OperatorException { AttributeWeights attributeWeights = new AttributeWeights(); for (Attribute attribute : exampleSet.getAttributes()) { attributeWeights.setWeight(attribute.getName(), 1); }@SuppressWarnings("unchecked") List<Object[]> list = getParameterList(WEIGHTING_PARAMETER); for (Object[] entry : list) { String regex = (String) entry[0]; Double weighting = (Double) entry[1]; if (regex != null && weighting != null) { try { Pattern pattern = Pattern.compile(regex); for (Attribute attribute : exampleSet.getAttributes()) { String attributeName = attribute.getName(); if (pattern.matcher(attributeName).matches()) { attributeWeights.setWeight(attributeName, weighting); } } } catch (PatternSyntaxException e) { logWarning(regex + " is not a valid regular expression!"); } } } return attributeWeights; }@Override public List<ParameterType> getParameterTypes() { List<ParameterType> parameters = super.getParameterTypes(); ParameterType weighting = new ParameterTypeList(WEIGHTING_PARAMETER, "Regex -> Weighting", new ParameterTypeDouble("weighting", "weighting", 0, Double.MAX_VALUE, false)); weighting.setExpert(false); parameters.add(weighting); return parameters; }}
mierswa wrote:Wow, that's fast 8)I would really like to add your contribution to the official release if you do not object. If this is ok to you, I would like to ask if you could sign the joint copyright assignment (known from Open Office, basically it only states that both parties, i.e. you and Rapid-I, have the copyright for the contribution) and send it to us. Then we are able to add the new operator to the official release. If you like to contribute, just download and sign the JCA underhttp://rapid-i.com/component/option,com_docman/task,doc_download/gid,26/Itemid,62/Since we have to adapt the code a bit anyway to stick to our coding standards, this is of course not too much of an issue but I would like to get things right first. Cheers,Ingo
Username wrote:Ok, I will sign the JCA and send it via old fashioned mail in the next days.
Join us for a community conversation on how High-Performance Computing (HPC) and Simcenter PSIM work together to meet the increasing demands of modern power electronics simulation. During this one-hour technical session, you'll discover how leveraging HPC can speed up simulations, improve scalability, and empower engineers…
Join us for a community conversation on accelerating your motor simulation workflow with Simcenter Simlab. In this beginner-friendly session, we'll introduce the platform's automated model-building capabilities and show how easy it is to set up your first electric motor analysis. You'll see the basic steps of geometry…
Join us for a Community Conversation where we'll discuss practical approaches to analyzing complex electromagnetic models using hybrid solver techniques. This session will provide a general overview of how different computational methods can be combined within a single simulation to address models containing varied…