如何在 ELKI 中不从文件源创建数据库?
How to create db not from file source in ELKI?
目前,我正在使用ELKI来研究R树。所以,我正在尝试从我的一组点中创建数据库。我可以使用基于文件的数据库连接轻松完成此操作:
ListParameterization spatparams = new ListParameterization();
spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID,RStarTreeFactory.class);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 300);
spatparams.addParameter(AbstractRStarTreeFactory.Parameterizer.INSERTION_STRATEGY_ID, ApproximativeLeastOverlapInsertionStrategy.class);
定义文件:
spatparams.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, "test.txt");
test.txt:
2.16130014186383 0.869922393308295 point1
1.95053629423729 2.33018306536426 point2
2.42579304519276 1.25052644952180 point3
初始化数据库:
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, spatparams);
db.initialize();
但我无法理解如何从定义的变量中获取它,如下所示:
DoubleVector point1 = DoubleVector.FACTORY.newNumberVector(new double[] { 2.16130014186383, 0.869922393308295});
DoubleVector point2 = DoubleVector.FACTORY.newNumberVector(new double[] { 1.95053629423729, 2.33018306536426});
DoubleVector point3 = DoubleVector.FACTORY.newNumberVector(new double[] { 2.42579304519276,1.25052644952180});
拜托,谁能解释一下如何从定义的双向量创建数据库?
查看文档:https://elki-project.github.io/howto/java_api#PureJavaAPI
// Adapter to load data from an existing array.
DatabaseConnection dbc = new ArrayAdapterDatabaseConnection(data);
// Create a database (which may contain multiple relations!)
Database db = new StaticArrayDatabase(dbc, null);
// Load the data into the database (do NOT forget to initialize...)
db.initialize();
如果需要索引加速,请将 null
替换为索引工厂。
目前,我正在使用ELKI来研究R树。所以,我正在尝试从我的一组点中创建数据库。我可以使用基于文件的数据库连接轻松完成此操作:
ListParameterization spatparams = new ListParameterization();
spatparams.addParameter(StaticArrayDatabase.Parameterizer.INDEX_ID,RStarTreeFactory.class);
spatparams.addParameter(AbstractPageFileFactory.Parameterizer.PAGE_SIZE_ID, 300);
spatparams.addParameter(AbstractRStarTreeFactory.Parameterizer.INSERTION_STRATEGY_ID, ApproximativeLeastOverlapInsertionStrategy.class);
定义文件:
spatparams.addParameter(FileBasedDatabaseConnection.Parameterizer.INPUT_ID, "test.txt");
test.txt:
2.16130014186383 0.869922393308295 point1
1.95053629423729 2.33018306536426 point2
2.42579304519276 1.25052644952180 point3
初始化数据库:
Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, spatparams);
db.initialize();
但我无法理解如何从定义的变量中获取它,如下所示:
DoubleVector point1 = DoubleVector.FACTORY.newNumberVector(new double[] { 2.16130014186383, 0.869922393308295});
DoubleVector point2 = DoubleVector.FACTORY.newNumberVector(new double[] { 1.95053629423729, 2.33018306536426});
DoubleVector point3 = DoubleVector.FACTORY.newNumberVector(new double[] { 2.42579304519276,1.25052644952180});
拜托,谁能解释一下如何从定义的双向量创建数据库?
查看文档:https://elki-project.github.io/howto/java_api#PureJavaAPI
// Adapter to load data from an existing array.
DatabaseConnection dbc = new ArrayAdapterDatabaseConnection(data);
// Create a database (which may contain multiple relations!)
Database db = new StaticArrayDatabase(dbc, null);
// Load the data into the database (do NOT forget to initialize...)
db.initialize();
如果需要索引加速,请将 null
替换为索引工厂。