本文整理汇总了Java中tech.tablesaw.api.Table.create方法的典型用法代码示例。如果您正苦于以下问题:Java Table.create方法的具体用法?Java Table.create怎么用?Java Table.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tech.tablesaw.api.Table
的用法示例。
在下文中一共展示了Table.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chart
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static BarChart<String, Number> chart(String title, IntColumn categoryColumn, NumericColumn numericColumn) {
Table t = Table.create("", categoryColumn, numericColumn);
t = t.sortDescendingOn(numericColumn.name());
final CategoryAxis categoryAxis = getCategoryAxis(t.categoryColumn(0));
final NumberAxis numberAxis = getNumberAxis(t.numericColumn(1));
final BarChart<String, Number> barChart = getBarChart(title, categoryAxis, numberAxis);
List<XYChart.Data<String, Number>> data = new ArrayList<>(categoryColumn.size());
for (int i = 0; i < categoryColumn.size(); i++) {
data.add(new XYChart.Data<>(categoryColumn.getString(i), numericColumn.getFloat(i)));
}
barChart.getData().add(getSeries(numericColumn, data));
return barChart;
}
示例2: labeledCentroids
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public Table labeledCentroids() {
Table table = Table.create("Centroids");
CategoryColumn labelColumn = new CategoryColumn("Cluster");
table.addColumn(labelColumn);
for (NumericColumn inputColumn : inputColumns) {
FloatColumn centroid = new FloatColumn(inputColumn.name());
table.addColumn(centroid);
}
double[][] centroids = model.centroids();
for (int i = 0; i < centroids.length; i++) {
labelColumn.appendCell(String.valueOf(i));
double[] values = centroids[i];
for (int k = 0; k < values.length; k++) {
table.floatColumn(k + 1).append((float) values[k]);
}
}
return table;
}
示例3: labeledCentroids
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public Table labeledCentroids() {
Table table = Table.create("Centroids");
CategoryColumn labelColumn = new CategoryColumn("Cluster");
table.addColumn(labelColumn);
for (NumericColumn inputColumn : inputColumns) {
FloatColumn centroid = new FloatColumn(inputColumn.name());
table.addColumn(centroid);
}
double[][] centroids = kMeans.centroids();
for (int i = 0; i < centroids.length; i++) {
labelColumn.appendCell(String.valueOf(i));
double[] values = centroids[i];
for (int k = 0; k < values.length; k++) {
table.floatColumn(k + 1).append((float) values[k]);
}
}
return table;
}
示例4: AssociationRuleMining
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public AssociationRuleMining(IntColumn sets, CategoryColumn items, double support) {
Table temp = Table.create("temp");
temp.addColumn(sets.copy());
temp.addColumn(items.toIntColumn());
temp.sortAscendingOn(sets.name(), items.name());
ViewGroup baskets = temp.splitOn(temp.column(0));
int[][] itemsets = new int[baskets.size()][];
int basketIndex = 0;
for (TemporaryView basket : baskets) {
IntRBTreeSet set = new IntRBTreeSet(basket.intColumn(1).data());
int itemIndex = 0;
itemsets[basketIndex] = new int[set.size()];
for (int item : set) {
itemsets[basketIndex][itemIndex] = item;
itemIndex++;
}
basketIndex++;
}
this.model = new ARM(itemsets, support);
}
示例5: main
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Table ops = Table.create("../data/operations.csv");
out(ops.structure());
out(ops);
DateTimeColumn start = ops.dateColumn("Date").atTime(ops.timeColumn("Start"));
DateTimeColumn end = ops.dateColumn("Date").atTime(ops.timeColumn("End"));
for (int row : ops) {
if (ops.timeColumn("End").get(row).isBefore(ops.timeColumn("Start").get(row))) {
end.get(row).plusDays(1);
}
}
// Calc duration
LongColumn duration = start.differenceInSeconds(end);
ops.addColumn(duration);
duration.setName("Duration");
out(ops);
Table q2_429_assembly = ops.selectWhere(
allOf
(column("date").isInQ2(),
(column("SKU").startsWith("429")),
(column("Operation").isEqualTo("Assembly"))));
Table durationByFacilityAndShift = q2_429_assembly.median("Duration").by("Facility", "Shift");
out(durationByFacilityAndShift);
durationByFacilityAndShift.write().csv("/tmp/durationByFacilityAndShift.csv");
}
示例6: defineSchema
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
private static Table defineSchema() {
Table t;
t = Table.create("Observations");
CategoryColumn conceptId = new CategoryColumn("concept");
DateColumn date = new DateColumn("date");
FloatColumn value = new FloatColumn("value");
IntColumn patientId = new IntColumn("patient");
t.addColumn(conceptId);
t.addColumn(date);
t.addColumn(value);
t.addColumn(patientId);
return t;
}
示例7: FrequentItemset
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public FrequentItemset(IntColumn sets, CategoryColumn items, double support) {
Table temp = Table.create("temp");
temp.addColumn(sets.copy());
IntColumn encodedItems = items.toIntColumn();
encodedItems.setName(items.name()); // Needs t
temp.addColumn(encodedItems);
temp.sortAscendingOn(sets.name(), items.name());
ViewGroup baskets = temp.splitOn(temp.column(0));
this.setCount = baskets.size();
int[][] itemsets = new int[setCount][];
int basketIndex = 0;
for (TemporaryView basket : baskets) {
IntRBTreeSet set = new IntRBTreeSet(basket.intColumn(1).data());
int itemIndex = 0;
itemsets[basketIndex] = new int[set.size()];
for (int item : set) {
itemsets[basketIndex][itemIndex] = item;
itemIndex++;
}
basketIndex++;
}
this.model = new FPGrowth(itemsets, support);
}
示例8: printNull
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
@Test
public void printNull() {
DoubleColumn col = new DoubleColumn("testCol");
col.append(5.0);
col.appendCell(null);
col.append(3.0);
Table table = Table.create("nullCellTable", col);
String out = table.print();
assertThat(out, containsString(" "));
}
示例9: setUp
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
table = Table.read().csv("../data/BushApproval.csv");
table = table.first(4);
table2 = Table.create("2 column version");
table2.addColumn(table.column(1), table.column(2));
}
示例10: emptyTableFromColumns
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
private Table emptyTableFromColumns(Table table1, Table table2, String col2Name) {
Column[] cols = Streams.concat(
table1.columns().stream(),
table2.columns().stream().filter(c -> !c.name().equals(col2Name))
).map(col -> col.columnMetadata().createColumn()).toArray(size -> new Column[size]);
return Table.create(table1.name(), cols);
}
示例11: where
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public Table where(Filter filter) {
Table projectedTable = Table.create(table.name(), columns);
Table newTable = projectedTable.emptyCopy();
Selection map = filter.apply(table);
Rows.copyRowsToTable(map, projectedTable, newTable);
return newTable;
}
示例12: reduce
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public Table reduce(String numericColumnName, AggregateFunction function) {
Preconditions.checkArgument(!subTables.isEmpty());
Table t = Table.create(original.name() + " summary");
CategoryColumn groupColumn = new CategoryColumn("Group", subTables.size());
FloatColumn resultColumn = new FloatColumn(function.functionName(), subTables.size());
t.addColumn(groupColumn);
t.addColumn(resultColumn);
for (SubTable subTable : subTables) {
double result = subTable.agg(numericColumnName, function);
groupColumn.append(subTable.name().replace(SPLIT_STRING, " * "));
resultColumn.append((float) result);
}
return t;
}
示例13: asTable
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public Table asTable() {
Table table = Table.create(this.name());
for (Column column : columns()) {
table.addColumn(column.subset(rowMap));
}
return table;
}
示例14: read
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
/**
* Returns a new table with the given tableName, constructed from the given result set
*
* @throws SQLException
*/
public static Table read(ResultSet resultSet, String tableName) throws SQLException {
ResultSetMetaData metaData = resultSet.getMetaData();
Table table = Table.create(tableName);
// Setup the columns and add to the table
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String name = metaData.getColumnName(i);
ColumnType type = SQL_TYPE_TO_TABLESAW_TYPE.get(metaData.getColumnType(i));
Preconditions.checkState(type != null,
"No column type found for %s as specified for column %s", metaData.getColumnType(i), name);
Column newColumn = TypeUtils.newColumn(name, type);
table.addColumn(newColumn);
}
// Add the rows
while (resultSet.next()) {
for (int i = 1; i <= metaData.getColumnCount(); i++) {
Column column = table.column(i - 1); // subtract 1 because results sets originate at 1 not 0
column.appendCell(resultSet.getString(i));
}
}
return table;
}
示例15: setUp
import tech.tablesaw.api.Table; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
Table table = Table.create("Test");
column1 = new DateColumn("Game date", Locale.ENGLISH);
table.addColumn(column1);
}