RapidMiner 7.3中API的变化
RapidMiner 7.3带来了两个影响扩展开发的变化。首先,用于创建数据集的中央API (ExampleSet
实例)被引入。第二,ExampleSet
接口被一个方法扩展,以允许释放未使用的数据。
只有当您的扩展包含生成新数据集或定义自己的操作符时,这些更改才会影响到您ExampleSet
S(例如,自定义视图)。
生成数据集
RapidMiner 7.3添加了ExampleSets
类,该类提供一组用于构建新数据集的静态方法。的直接实例化ExampleTable
实现,例如MemoryExampleTable
.类的所有公共构造函数MemoryExampleTable
类已弃用。
新的API提供了从列数据和面向行数据创建数据集的方法:
进口com.rapidminer.example.Attribute;进口com.rapidminer.example.Attributes;进口com.rapidminer.example.ExampleSet;进口com.rapidminer.example.table.AttributeFactory;进口com.rapidminer.example.table.BinominalMapping;进口com.rapidminer.example.table.NominalMapping;进口com.rapidminer.example.utils.ExampleSetBuilder;进口com.rapidminer.example.utils.ExampleSets;进口com.rapidminer.operator.Operator;进口com.rapidminer.operator.OperatorDescription; import com.rapidminer.operator.OperatorException; import com.rapidminer.tools.Ontology; // create example set using column fillers Attribute topTen = AttributeFactory.createAttribute("Top Ten Numbers", Ontology.INTEGER); Attribute coinFlip = AttributeFactory.createAttribute("Coin Flip", Ontology.BINOMINAL); NominalMapping coin = new BinominalMapping(); int heads = coin.mapString("Heads"); int tails = coin.mapString("Tails"); coinFlip.setMapping(coin); ExampleSet numbers = ExampleSets.from(topTen, coinFlip) .withRole(topTen, Attributes.ID_NAME) .withBlankSize(10) .withColumnFiller(topTen, i -> i + 1) .withColumnFiller(coinFlip, i -> Math.random() < 0.5 ? heads : tails) .build(); // create example set from double matrix ExampleSetBuilder builder = ExampleSets.from(AttributeFactory.createAttribute(Ontology.REAL), AttributeFactory.createAttribute(Ontology.REAL), AttributeFactory.createAttribute(Ontology.REAL)); builder.withExpectedSize(10); double rawData[][] = new double[10][3]; for (double[] row : rawData) { builder.addRow(row); } ExampleSet matrix = builder.build();
释放未使用的资源乐鱼体育安装
的ExampleSet
接口已经被扩展清理()
方法。RapidMiner将在进程执行的某些点调用此方法,例如,在操作符之间。请注意,默认实现不做任何事情。
/** *释放未使用的资源,如果实现支乐鱼体育安装持的话。默认情况下不执行任何操作。* *应该只在新{@link #clone} {@link ExampleSet}上使用,以确保*清理的资源之后不会被请求。乐鱼体育安装* * @since 7.3 */ public default void cleanup(){//默认不做任何事情}
在实现管理其自身资源的自定义示例集时,请使用此方法释放未使用的数据,如临时属性。乐鱼体育安装
如果您不管理自己的资源,而是实现自定义乐鱼体育安装ExampleSet
作为另一个数据集上的视图,请相应地委派调用。
例如,大多数RapidMiner的视图实现都引用单个视图父
设置示例。因此,他们的实施清理()
可以归结为:
@Override public void cleanup() {parent.cleanup();}