本文整理了Java中eu.amidst.core.datastream.Attributes.getFullListOfAttributes()
方法的一些代码示例,展示了Attributes.getFullListOfAttributes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attributes.getFullListOfAttributes()
方法的具体详情如下:
包路径:eu.amidst.core.datastream.Attributes
类名称:Attributes
方法名:getFullListOfAttributes
暂无
代码示例来源:origin: amidst/toolbox
/**
* {@inheritDoc}
*/
@Override
default String outputString(){
StringBuilder builder = new StringBuilder(this.getAttributes().getFullListOfAttributes().size()*2);
builder.append("{");
this.getAttributes().getFullListOfAttributes().stream().forEach(att -> builder.append(att.getName()+ " = "+ att.stringValue(this.getValue(att))+", "));
builder.append("}");
return builder.toString();
}
}
代码示例来源:origin: amidst/toolbox
@Override
public void open(Configuration parameters) throws Exception{
super.open(parameters);
String relationName = parameters.getString(DataFlinkLoader.RELATION_NAME,"");
Collection<Attributes> collection = getRuntimeContext().getBroadcastVariable(DataFlinkLoader.ATTRIBUTES_NAME+"_"+relationName);
attributes = collection.iterator().next();
if(normalize) {
attributesToNormalize = attributes.getFullListOfAttributes().stream()
.filter(att -> att.getStateSpaceType().getStateSpaceTypeEnum() == StateSpaceTypeEnum.REAL)
.filter(att -> ((RealStateSpace) att.getStateSpaceType()).getMinInterval() != Double.NEGATIVE_INFINITY)
.filter(att -> ((RealStateSpace) att.getStateSpaceType()).getMaxInterval() != Double.POSITIVE_INFINITY)
.collect(Collectors.toList());
}
}
代码示例来源:origin: amidst/toolbox
static StructType getSchema(Attributes atts) {
// Generate the schema based on the list of attributes and depending on their type:
List<StructField> fields = new ArrayList<StructField>();
for (Attribute att: atts.getFullListOfAttributes()) {
if (att.getStateSpaceType().getStateSpaceTypeEnum() == REAL)
fields.add(DataTypes.createStructField(att.getName(), DataTypes.DoubleType, true));
else
fields.add(DataTypes.createStructField(att.getName(), DataTypes.StringType, true));
}
return DataTypes.createStructType(fields);
}
代码示例来源:origin: amidst/toolbox
private static Row transformArray2RowAttributes(DataInstance inst, Attributes atts) {
double[] values = inst.toArray();
Object[] rowValues = new Object[values.length];
for (int a = 0; a < atts.getNumberOfAttributes(); a++) {
Attribute attribute = atts.getFullListOfAttributes().get(a);
StateSpaceType domain = attribute.getStateSpaceType();
if (domain.getStateSpaceTypeEnum() == REAL)
rowValues[a] = new Double(values[a]);
else
rowValues[a] = domain.stringValue(values[a]);
}
return RowFactory.create(rowValues);
}
}
代码示例来源:origin: amidst/toolbox
public static void main(String[] args) throws Exception{
int nContinuousAttributes=0;
int nDiscreteAttributes=5;
String names[] = {"SEQUENCE_ID", "TIME_ID","DEFAULT","Income","Expenses","Balance","TotalCredit"};
String path = "datasets/simulated/";
int nSamples=1000;
String filename="bank_data_test";
int seed = filename.hashCode();
//Generate random dynamic data
DataStream<DynamicDataInstance> data = DataSetGenerator.generate(seed,nSamples,nDiscreteAttributes,nContinuousAttributes);
List<Attribute> list = new ArrayList<Attribute>();
//Replace the names
IntStream.range(0, data.getAttributes().getNumberOfAttributes())
.forEach(i -> {
Attribute a = data.getAttributes().getFullListOfAttributes().get(i);
StateSpaceType s = a.getStateSpaceType();
Attribute a2 = new Attribute(a.getIndex(), names[i],s);
list.add(a2);
});
//New list of attributes
Attributes att2 = new Attributes(list);
List<DynamicDataInstance> listData = data.stream().collect(Collectors.toList());
//Datastream with the new attribute names
DataStream<DynamicDataInstance> data2 =
new DataOnMemoryListContainer<DynamicDataInstance>(att2,listData);
//Write to a single file
DataStreamWriter.writeDataToFile(data2, path+filename+".arff");
}
代码示例来源:origin: amidst/toolbox
public static void main(String[] args) throws Exception{
int nContinuousAttributes=4;
int nDiscreteAttributes=1;
String names[] = {"SEQUENCE_ID", "TIME_ID","Default","Income","Expenses","Balance","TotalCredit"};
String path = "datasets/simulated/";
int nSamples=1000;
int seed = 11234;
String filename="bank_data_test";
//Generate random dynamic data
DataStream<DynamicDataInstance> data = DataSetGenerator.generate(seed,nSamples,nDiscreteAttributes,nContinuousAttributes);
List<Attribute> list = new ArrayList<Attribute>();
//Replace the names
IntStream.range(0, data.getAttributes().getNumberOfAttributes())
.forEach(i -> {
Attribute a = data.getAttributes().getFullListOfAttributes().get(i);
StateSpaceType s = a.getStateSpaceType();
Attribute a2 = new Attribute(a.getIndex(), names[i],s);
list.add(a2);
});
//New list of attributes
Attributes att2 = new Attributes(list);
List<DynamicDataInstance> listData = data.stream().collect(Collectors.toList());
//Datastream with the new attribute names
DataStream<DynamicDataInstance> data2 =
new DataOnMemoryListContainer<DynamicDataInstance>(att2,listData);
//Write to a single file
DataStreamWriter.writeDataToFile(data2, path+filename+".arff");
}
代码示例来源:origin: amidst/toolbox
private static double[] transformRow2DataInstance(Row row, Attributes attributes) throws Exception {
double[] instance = new double[row.length()];
for (int i = 0; i < row.length(); i++) {
Attribute att = attributes.getFullListOfAttributes().get(i);
StateSpaceType space = att.getStateSpaceType();
switch (space.getStateSpaceTypeEnum()) {
case REAL:
instance[i] = row.getDouble(i);
break;
case FINITE_SET:
String state = row.getString(i);
double index = ((FiniteStateSpace) space).getIndexOfState(state);
instance[i] = index;
break;
default:
// This should never execute
throw new Exception("Unrecognized Error");
}
}
return instance;
}
代码示例来源:origin: amidst/toolbox
/**
* Builds the DAG over the set of variables given with the structure of the model
*/
@Override
protected void buildDAG() {
String className = atts.getFullListOfAttributes().get(classIndex).getName();
hiddenVars = new ArrayList<Variable>();
for (int i = 0; i < this.numberOfGlobalVars ; i++) {
hiddenVars.add(vars.newGaussianVariable("GlobalHidden_"+i));
}
Variable classVariable = vars.getVariableByName(className);
dag = new DAG(vars);
for (Attribute att : atts.getListOfNonSpecialAttributes()) {
if (att.getName().equals(className))
continue;
Variable variable = vars.getVariableByName(att.getName());
dag.getParentSet(variable).addParent(classVariable);
if (this.globalHidden) {
for (int i = 0; i < this.numberOfGlobalVars ; i++) {
dag.getParentSet(variable).addParent(hiddenVars.get(i));
}
}
}
}
代码示例来源:origin: amidst/toolbox
/**
* Builds the DAG structure of a Naive Bayes classifier with a global hidden Gaussian variable.
*/
private void buildGlobalDAG(){
Variables variables = new Variables(attributes);
String className = attributes.getFullListOfAttributes().get(classIndex).getName();
hiddenVars = new ArrayList<Variable>();
for (int i = 0; i < this.numberOfGlobalVars ; i++) {
hiddenVars.add(variables.newGaussianVariable("GlobalHidden_"+i));
}
Variable classVariable = variables.getVariableByName(className);
this.globalDAG = new DAG(variables);
for (Attribute att : attributes.getListOfNonSpecialAttributes()) {
if (att.getName().equals(className))
continue;
Variable variable = variables.getVariableByName(att.getName());
globalDAG.getParentSet(variable).addParent(classVariable);
for (int i = 0; i < this.numberOfGlobalVars ; i++) {
globalDAG.getParentSet(variable).addParent(hiddenVars.get(i));
}
}
System.out.println(globalDAG.toString());
}
代码示例来源:origin: amidst/toolbox
public static <T extends DataInstance> void writeHeader(ExecutionEnvironment env, DataFlink<T> data, String path,
boolean includeRanges) {
DataSource<String> name = env.fromElements("@relation " + data.getName());
name.writeAsText(path + "/name.txt", FileSystem.WriteMode.OVERWRITE);
DataSource<Attribute> attData = env.fromCollection(data.getAttributes().getFullListOfAttributes());
attData.writeAsFormattedText(path + "/attributes.txt", FileSystem.WriteMode.OVERWRITE, new TextOutputFormat.TextFormatter<Attribute>() {
@Override
public String format(Attribute att) {
return ARFFDataWriter.attributeToARFFStringWithIndex(att,includeRanges);
}
});
}
}
代码示例来源:origin: amidst/toolbox
model.setClassName(data.getAttributes().getFullListOfAttributes().get(data.getAttributes().getFullListOfAttributes().size() - 1).getName());
model.updateModel(data);
BayesianNetwork nbClassifier = model.getModel();
代码示例来源:origin: amidst/toolbox
nameRoot = data.getAttributes().getFullListOfAttributes().get(numDiscVars - 1).getName();
nameTarget = data.getAttributes().getFullListOfAttributes().get(0).getName();
代码示例来源:origin: amidst/toolbox
String className = attributes.getFullListOfAttributes().get(classIndex).getName();
hiddenVars = new ArrayList<Variable>();
代码示例来源:origin: amidst/toolbox
Attribute a = data.getAttributes().getFullListOfAttributes().get(i);
StateSpaceType s = a.getStateSpaceType();
Attribute a2 = new Attribute(a.getIndex(), names[i],s);
代码示例来源:origin: amidst/toolbox
Attribute atttime = new Attribute(data.getAttributes().getNumberOfAttributes()+1,Attributes.TIME_ID_ATT_NAME, new RealStateSpace());
List<Attribute> attributeList = data.getAttributes().getFullListOfAttributes();
List<Attribute> att2 =attributeList.stream().map(at -> at).collect(Collectors.toList());
att2.add(attseq);
代码示例来源:origin: amidst/toolbox
Attribute atttime = new Attribute(data.getAttributes().getNumberOfAttributes()+1,Attributes.TIME_ID_ATT_NAME, new RealStateSpace());
List<Attribute> attributeList = data.getAttributes().getFullListOfAttributes();
List<Attribute> att2 =attributeList.stream().map(at -> at).collect(Collectors.toList());
att2.add(attseq);
代码示例来源:origin: amidst/toolbox
nameRoot = data.getAttributes().getFullListOfAttributes().get(numDiscVars - 1).getName();
nameTarget = data.getAttributes().getFullListOfAttributes().get(0).getName();
代码示例来源:origin: amidst/toolbox
nameRoot = data.getAttributes().getFullListOfAttributes().get(numDiscVars - 1).getName();
nameTarget = data.getAttributes().getFullListOfAttributes().get(0).getName();
内容来源于网络,如有侵权,请联系作者删除!