Search in sources :

Example 21 with Dataset

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);
    }
}
Also used : Dataset(com.google.cloud.automl.v1beta1.Dataset) VideoObjectTrackingDatasetMetadata(com.google.cloud.automl.v1beta1.VideoObjectTrackingDatasetMetadata) AutoMlClient(com.google.cloud.automl.v1beta1.AutoMlClient) LocationName(com.google.cloud.automl.v1beta1.LocationName)

Example 22 with Dataset

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);
    }
}
Also used : Dataset(com.google.cloud.automl.v1.Dataset) TextExtractionDatasetMetadata(com.google.cloud.automl.v1.TextExtractionDatasetMetadata) OperationMetadata(com.google.cloud.automl.v1.OperationMetadata) AutoMlClient(com.google.cloud.automl.v1.AutoMlClient) LocationName(com.google.cloud.automl.v1.LocationName)

Example 23 with Dataset

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());
        }
    }
}
Also used : TablesModelColumnInfo(com.google.cloud.automl.v1beta1.TablesModelColumnInfo) ModelName(com.google.cloud.automl.v1beta1.ModelName) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Model(com.google.cloud.automl.v1beta1.Model) SimpleDateFormat(java.text.SimpleDateFormat) AutoMlClient(com.google.cloud.automl.v1beta1.AutoMlClient)

Example 24 with Dataset

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);
}
Also used : ActivityDescription(spold2.ActivityDescription) DataSet(spold2.DataSet) UserMasterData(spold2.UserMasterData) File(java.io.File)

Example 25 with Dataset

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);
}
Also used : ChannelRecordContainer(org.openmuc.framework.driver.spi.ChannelRecordContainer) DataSet(org.openmuc.j62056.DataSet) DoubleValue(org.openmuc.framework.data.DoubleValue) ArrayList(java.util.ArrayList) Record(org.openmuc.framework.data.Record) StringValue(org.openmuc.framework.data.StringValue)

Aggregations

IOException (java.io.IOException)15 AutoMlClient (com.google.cloud.automl.v1beta1.AutoMlClient)13 Dataset (com.google.cloud.datalabeling.v1beta1.Dataset)9 ArrayList (java.util.ArrayList)9 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)8 Dataset (com.google.cloud.automl.v1.Dataset)8 LocationName (com.google.cloud.automl.v1.LocationName)7 LocationName (com.google.cloud.automl.v1beta1.LocationName)7 DataLabelingServiceClient (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient)7 ProjectName (com.google.cloud.datalabeling.v1beta1.ProjectName)7 OperationMetadata (com.google.cloud.automl.v1.OperationMetadata)6 Dataset (com.google.cloud.automl.v1beta1.Dataset)6 DataSet (org.openmuc.j62056.DataSet)6 DatasetName (com.google.cloud.automl.v1beta1.DatasetName)5 ListDatasetsPagedResponse (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient.ListDatasetsPagedResponse)5 ListDatasetsRequest (com.google.cloud.datalabeling.v1beta1.ListDatasetsRequest)5 DataField (org.idempiere.adInterface.x10.DataField)5 DataRow (org.idempiere.adInterface.x10.DataRow)5 DataSet (org.idempiere.adInterface.x10.DataSet)5 WindowTabData (org.idempiere.adInterface.x10.WindowTabData)5