use of com.google.cloud.automl.v1beta1.Dataset in project java-automl by googleapis.
the class VideoObjectTrackingCreateDataset method createDataset.
// Create a dataset
static void createDataset(String projectId, String displayName) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// A resource that represents Google Cloud Platform location.
LocationName projectLocation = LocationName.of(projectId, "us-central1");
VideoObjectTrackingDatasetMetadata metadata = VideoObjectTrackingDatasetMetadata.newBuilder().build();
Dataset dataset = Dataset.newBuilder().setDisplayName(displayName).setVideoObjectTrackingDatasetMetadata(metadata).build();
Dataset createdDataset = client.createDataset(projectLocation, dataset);
// Display the dataset information.
System.out.format("Dataset name: %s%n", createdDataset.getName());
// To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
// required for other methods.
// Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
String[] names = createdDataset.getName().split("/");
String datasetId = names[names.length - 1];
System.out.format("Dataset id: %s%n", datasetId);
}
}
use of com.google.cloud.automl.v1beta1.Dataset in project java-automl by googleapis.
the class LanguageEntityExtractionCreateDataset method createDataset.
// Create a dataset
static void createDataset(String projectId, String displayName) throws IOException, ExecutionException, InterruptedException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// A resource that represents Google Cloud Platform location.
LocationName projectLocation = LocationName.of(projectId, "us-central1");
TextExtractionDatasetMetadata metadata = TextExtractionDatasetMetadata.newBuilder().build();
Dataset dataset = Dataset.newBuilder().setDisplayName(displayName).setTextExtractionDatasetMetadata(metadata).build();
OperationFuture<Dataset, OperationMetadata> future = client.createDatasetAsync(projectLocation, dataset);
Dataset createdDataset = future.get();
// Display the dataset information.
System.out.format("Dataset name: %s\n", createdDataset.getName());
// To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
// required for other methods.
// Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
String[] names = createdDataset.getName().split("/");
String datasetId = names[names.length - 1];
System.out.format("Dataset id: %s\n", datasetId);
}
}
use of com.google.cloud.automl.v1beta1.Dataset in project java-automl by googleapis.
the class TablesGetModel method getModel.
// Demonstrates using the AutoML client to get model details.
public static void getModel(String projectId, String computeRegion, String modelId) throws IOException, StatusRuntimeException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// Get the full path of the model.
ModelName modelFullId = ModelName.of(projectId, computeRegion, modelId);
// Get complete detail of the model.
Model model = client.getModel(modelFullId);
// Display the model information.
System.out.format("Model name: %s%n", model.getName());
System.out.format("Model Id: %s\n", model.getName().split("/")[model.getName().split("/").length - 1]);
System.out.format("Model display name: %s%n", model.getDisplayName());
System.out.format("Dataset Id: %s%n", model.getDatasetId());
System.out.println("Tables Model Metadata: ");
System.out.format("\tTraining budget: %s%n", model.getTablesModelMetadata().getTrainBudgetMilliNodeHours());
System.out.format("\tTraining cost: %s%n", model.getTablesModelMetadata().getTrainBudgetMilliNodeHours());
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
String createTime = dateFormat.format(new java.util.Date(model.getCreateTime().getSeconds() * 1000));
System.out.format("Model create time: %s%n", createTime);
System.out.format("Model deployment state: %s%n", model.getDeploymentState());
// Get features of top importance
for (TablesModelColumnInfo info : model.getTablesModelMetadata().getTablesModelColumnInfoList()) {
System.out.format("Column: %s - Importance: %.2f%n", info.getColumnDisplayName(), info.getFeatureImportance());
}
}
}
use of com.google.cloud.automl.v1beta1.Dataset in project olca-modules by GreenDelta.
the class EcoSpold2Export method exportProcess.
public void exportProcess(Process process) {
var ds = new DataSet();
ds.description = new ActivityDescription();
ds.masterData = new UserMasterData();
mapActivity(process, ds);
mapLocation(process, ds);
ProcessDoc.map(process, ds);
mapExchanges(process, ds);
mapParameters(process, ds);
MasterData.writeIndexEntry(ds);
var fileName = process.refId == null ? UUID.randomUUID().toString() : process.refId;
var file = new File(activityDir, fileName + ".spold");
EcoSpold2.write(ds, file);
}
use of com.google.cloud.automl.v1beta1.Dataset in project OpenMUC by isc-konstanz.
the class Iec62056Listener method newRecord.
private synchronized void newRecord(List<DataSet> dataSets, long time) {
List<ChannelRecordContainer> newContainers = new ArrayList<>();
for (ChannelRecordContainer container : containers) {
for (DataSet dataSet : dataSets) {
if (dataSet.getAddress().equals(container.getChannelAddress())) {
String value = dataSet.getValue();
if (value != null) {
try {
container.setRecord(new Record(new DoubleValue(Double.parseDouble(dataSet.getValue())), time));
newContainers.add(container);
} catch (NumberFormatException e) {
container.setRecord(new Record(new StringValue(dataSet.getValue()), time));
}
}
break;
}
}
}
listener.newRecords(newContainers);
}
Aggregations