"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/main/java/com/rapidminer/operator/ports/metadata/ExampleSetMetaData.java" between
rapidminer-studio-9.4.1-src.tar.gz and rapidminer-studio-9.5.0-src.tar.gz

About: RapidMiner Studio is a code-free environment for designing advanced analytic processes with machine learning, data mining, text mining, predictive analytics and business analytics. Java source.

ExampleSetMetaData.java  (rapidminer-studio-9.4.1-src):ExampleSetMetaData.java  (rapidminer-studio-9.5.0-src)
skipping to change at line 31 skipping to change at line 31
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.rapidminer.RapidMiner; import com.rapidminer.RapidMiner;
import com.rapidminer.adaption.belt.IOTable; import com.rapidminer.adaption.belt.IOTable;
import com.rapidminer.adaption.belt.TableViewingTools; import com.rapidminer.adaption.belt.TableViewingTools;
import com.rapidminer.belt.column.Column;
import com.rapidminer.belt.table.BeltConverter;
import com.rapidminer.belt.table.Table;
import com.rapidminer.example.AttributeRole; import com.rapidminer.example.AttributeRole;
import com.rapidminer.example.Attributes; import com.rapidminer.example.Attributes;
import com.rapidminer.example.ExampleSet; import com.rapidminer.example.ExampleSet;
import com.rapidminer.tools.Ontology; import com.rapidminer.tools.Ontology;
import com.rapidminer.tools.ParameterService; import com.rapidminer.tools.ParameterService;
import com.rapidminer.tools.Tools; import com.rapidminer.tools.Tools;
/** /**
* This class stores detailed meta data information about ExampleSets. * This class stores detailed meta data information about ExampleSets.
* *
skipping to change at line 121 skipping to change at line 124
* @param exampleSet * @param exampleSet
* the ExampleSet object the meta-data should be constructed f or * the ExampleSet object the meta-data should be constructed f or
* @param shortened * @param shortened
* whether the meta data should be shortened. In case it shoul d be shortened the * whether the meta data should be shortened. In case it shoul d be shortened the
* meta-data will contain at most {@link #getMaximumNumberOfAt tributes()} attributes * meta-data will contain at most {@link #getMaximumNumberOfAt tributes()} attributes
* @param recalculateStatistics * @param recalculateStatistics
* defines whether the ExampleSet statistics should be recalcu lated * defines whether the ExampleSet statistics should be recalcu lated
*/ */
public ExampleSetMetaData(ExampleSet exampleSet, boolean shortened, boole an recalculateStatistics) { public ExampleSetMetaData(ExampleSet exampleSet, boolean shortened, boole an recalculateStatistics) {
super(ExampleSet.class); super(ExampleSet.class);
create(exampleSet, shortened, recalculateStatistics);
}
/**
* Adds {@link AttributeMetaData} according to the given {@link ExampleSe
t}.
*
* @param exampleSet
* the ExampleSet object the meta-data should be constructed
for
* @param shortened
* whether the meta data should be shortened. In case it sho
uld be shortened the meta-data will contain at
* most
* {@link #getMaximumNumberOfAttributes()} attributes
* @param recalculateStatistics
* defines whether the ExampleSet statistics should be recal
culated
*/
private void create(ExampleSet exampleSet, boolean shortened, boolean rec
alculateStatistics) {
int maxNumber = Integer.MAX_VALUE; int maxNumber = Integer.MAX_VALUE;
if (shortened) { if (shortened) {
maxNumber = getMaximumNumberOfAttributes(); maxNumber = getMaximumNumberOfAttributes();
} }
if (recalculateStatistics) { if (recalculateStatistics) {
try { try {
exampleSet.recalculateAllAttributeStatistics(); exampleSet.recalculateAllAttributeStatistics();
} catch (UnsupportedOperationException e) { } catch (UnsupportedOperationException e) {
// May not be supported by HeaderExampleSet // May not be supported by HeaderExampleSet
} }
skipping to change at line 145 skipping to change at line 164
addAttribute(new AttributeMetaData(role, exampleSet, shor tened)); addAttribute(new AttributeMetaData(role, exampleSet, shor tened));
maxNumber--; maxNumber--;
if (maxNumber == 0) { if (maxNumber == 0) {
break; break;
} }
} }
numberOfExamples = new MDInteger(exampleSet.size()); numberOfExamples = new MDInteger(exampleSet.size());
} }
public ExampleSetMetaData(IOTable tableObject, boolean shortened) { public ExampleSetMetaData(IOTable tableObject, boolean shortened) {
this(TableViewingTools.getView(tableObject), shortened, !shortene super(ExampleSet.class);
d); try {
create(TableViewingTools.getView(tableObject), shortened,
!shortened);
} catch (BeltConverter.ConversionException e) {
//clear meta data in case some were added before the exce
ption
attributeMetaData.clear();
handleWithCustom(tableObject, shortened);
}
}
/**
* In case the tableObject contains custom columns, creates meta data for
the table without custom columns and then
* adds the custom columns with {@link Ontology#ATTRIBUTE_VALUE}.
*
* @param tableObject
* the table object for which to create meta data
* @param shortened
* whether the meta data should be shortened. In case it sho
uld be shortened the meta-data will contain at
* most {@link #getMaximumNumberOfAttributes()} attributes
*/
private void handleWithCustom(IOTable tableObject, boolean shortened) {
Table table = tableObject.getTable();
Table tableWithoutCustoms = table.columns(table.select().notOfTyp
eId(Column.TypeId.CUSTOM).labels());
ExampleSet view = TableViewingTools.getView(new IOTable(tableWith
outCustoms));
create(view, shortened, !shortened);
int maxNumber = Integer.MAX_VALUE;
if (shortened) {
maxNumber = getMaximumNumberOfAttributes();
}
maxNumber -= attributeMetaData.size();
if (maxNumber > 0) {
for (String custom : table.select().ofTypeId(Column.TypeI
d.CUSTOM).labels()) {
String role = BeltConverter.convertRole(table, cu
stom);
addAttribute(new AttributeMetaData(custom, Ontolo
gy.ATTRIBUTE_VALUE, role));
maxNumber--;
if (maxNumber == 0) {
break;
}
}
}
} }
public AttributeMetaData getAttributeByName(String name) { public AttributeMetaData getAttributeByName(String name) {
return attributeMetaData.get(name); return attributeMetaData.get(name);
} }
public AttributeMetaData getAttributeByRole(String role) { public AttributeMetaData getAttributeByRole(String role) {
for (AttributeMetaData amd : attributeMetaData.values()) { for (AttributeMetaData amd : attributeMetaData.values()) {
String currentRole = amd.getRole(); String currentRole = amd.getRole();
if (currentRole != null && currentRole.equals(role)) { if (currentRole != null && currentRole.equals(role)) {
 End of changes. 3 change blocks. 
2 lines changed or deleted 73 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)