POST /predict hippocrates vision, model API

This method allows users to request a petition to a given deployed API from a trained vision hippocrates model

Request

The Following structure must be followed

{ zip_gcloud : str, label_cols : list <str>, images_col : str, model_type : int, optimization_type : int, experiment_id : int, user_token : str, user_id : str, study_type : str, type_of_experiment : str, task : str, data_cols : list<str>, optimization_metric : str }

Request specifications

  • zip_gcloud : Download link of the .zip file in the Google Cloud bucket (EJ: “User_X/Experiment-#X/file.zip”)
  • label_cols : NAME of the column that contains the labels that the algorithm will use in the training/validation/testing process (EJ: [“label”])
  • images_col : NAME of the column that contains the complete path of the images used for the training/validation/testing process (only if @task is “vision”) (EJ: “ruta”)
  • model_type : Defines the type of algorithm that will be generated
    • int 0 : Classification algorithm
    • int 1 : Regression algorithm
  • optimization_type : Defines the priority for the creation of the algorithm
    • int 0 : Prioritize precision
    • int 1 : Prioritize time
  • experiment_id : Number set to identify the experiment
  • user_token : Token to identify the user with @user_id
  • user_id : a string that identifys the User running the experiment
  • study_type : Defines the type of studiy being performed
    • “Hippocrates” : Building a model of @model_type defined
    • “Retrospective” : Building a retrospective study to test a model on given data (not implemented yet)
  • task : Defines the type of task that need to solve the algorithm
    • “vision” : an algorithm that only uses images as input
    • “data” : an algorithm that uses structured data as input
  • data_cols : Column NAMES containint the structured data that Hippocrated must use to build the algorithm (EJ: [“Column1”, “Column2”, etc]
  • optimization_metric : defines the metric that will be taken into account for evaluation of the algorithm
    • “AUC”
    • “F-macro”
    • “Precision”
    • “Recall”
  • body can’t be empty and must include a direct link to a valid image uri string. Request body must follow this structure: {“message”: uri (string)}

Response

If succeeds, returns the created thing.

Status: 201 Created { prediccion: list<Boolean>, score: dict, classes: dict, error: boolean columnas: int filas:int gradients:dict }

Response specifications

  • “error”: Returns 0 for a succesful prediction otherwise it’s 1.
  • “classes”: Dictionary with class semantic meanings, ex: {“0”:”Normal”, “1”:”Patológica”}.
  • “prediccion”: List of binary values with length equal to class numbers, if class i is predicted as positive, it is returned with a value of 1, otherwise, it’s 0
  • “score”: List of float, contains model scores for each prediction, has the same length as prediccion
  • “filas”: Int, not relevant for user.
  • “columnas”: Int, not relevant for user.
  • “gradients”: Dictionary with keys related to each position i for which prediccion returned 1. Values correspond to a list of lists (Activation values per pixel in range [0-255]) for each of these keys. Ex: {“1”:<list<list>>}

POST /predict hippocrates object detection, model API

This method allows users to request a petition to a given deployed API from a trained object detection hippocrates model

Request

  • body can’t be empty and must include a direct link to a valid image uri string. Request body must follow this structure: {“message”: uri (string)}

Response

If succeeds, returns an object detection prediction.

Status: 201 Created { boxes: list score: dict, classification: int error: boolean }

Response specifications

  • “error”: Returns 0 for a succesful prediction otherwise it’s 1.
  • “score”: List of float, contains model scores for each prediction, has the same length as prediccion
  • *“boxes”: List of all detected objects, contains bounding boxes in the format (x1,y1,x2,y2)
  • “classification”: List of integers in the same order as boxes and scores, provides class for each detected object

POST /predict hippocrates data, model API

This method allows users to request a petition to a given deployed API from a trained data hippocrates model

Request

  • body can’t be empty and must include an array of clinical variables of type float. Request body must follow this structure: {“message”: <Array>}

Response

If succeeds, returns a prediction JSON.

Status: 201 Created { prediccion: list<Boolean>, score: dict, classes: dict, error: boolean }

Response specifications

  • “error”: Returns 0 for a succesful prediction otherwise it’s 1.
  • “classes”: Dictionary with class semantic meanings, ex: {“0”:”Normal”, “1”:”Patológica”}.
  • “prediccion”: List of binary values with length equal to class numbers, if class i is predicted as positive, it is returned with a value of 1, otherwise, it’s 0
  • “score”: List of float, contains model scores for each prediction, has the same length as prediccion

POST /predict hippocrates csv vision tutorial

This entry will show you how to create your .CSV file to upload to the Hippocrates platform. Notably, in this case, we will show you the structure for a .CSV file intended to construct a vision algorithm.

Vision algorithms are those that receive Images as input. So we will build a file taking into account the saving paths for each image.

Let’s pretend we have a set of images as shown bellow

These images are stored in separate directories named Benign_Masses and Malignant_Masses respectively

In that sense, when we create the .csv file, we have to consider the whole path to each of the images.

CSV column requirements

Hippocrates is designed in a way that it can process a CSV automatically without needing an expert to analyze the file. To achieve this automatization, some requirements must be fulfilled. Notably, for a vision algorithm, this file requires a minimum 3 columns:

  • First column: You must assign an identification number to each patient in this column. As the information must be anonymized, this identification number cannot be the ID of the patient but a number assigned in the creation of the database. This number is vital for creating the algorithm, as it will be used to properly manage the presence of numerous images for the same patient.

  • Second column: In this column, you will define the path assigned to each image. Here it is crucial to ensure that the paths have no spaces or special characters like parenthesis or square brackets. If your paths have such characters by any chance, please replace them using a “_”. For example, If the path to any image is something like “Directory/SubDirectory name/image (1).png,” you must correct it using the underscore as follows like “Directory/SubDirectory_name/image_1.png”.

  • Third column: In this column, you will assign the gold standard that the algorithm must recognize in the images. In other words, you will give a class to each image. We strongly recommend using a number code to identify each class and not the string. That is to say, if there are two classes, let’s say “Benning” and “Malignant,” instead of writing in this third column “Benning” or “Malignant,” we could assign the code number 0 to the images corresponding to “Benning,” and the code number 1 to images corresponding to “Malignant,”

That said, it is crucial that when you build your CSV file you remember the name that you assigned for each of the columns described above, as the Hippocrates form will ask you for the name of the columns.

Below you can find an example of a CSV file created for the study case that we have stated before

In this particular case, as you may recognize, there are several images for the same patient, and there is a forth column that we used to remember the name for each class

Zip file

Once you have the CSV file organized as described, you must ZIP it together with the images into a .zip file. Here is vital to remember that the directories structure that you use to define the images path in the CSV must be the same that you use when zipping the files. In that sense the zip file, for our study case is structure as follows

POST /predict hippocrates csv data tutorial

This entry will show you how to create your .CSV file to upload to the Hippocrates platform. Notably, in this case, we will show you the structure for a .CSV file intended to construct a vision algorithm.

Data algorithms are those that receive an structured DataFrame as input.

CSV column requirements

Hippocrates is designed in a way that it can process a CSV automatically without needing an expert to analyze the file. To achieve this automatization, some requirements must be fulfilled. Notably, for a data algorithm, this file requires a minimum 3 columns:

  • First column: You must assign an identification number to each patient in this column. As the information must be anonymized, this identification number cannot be the ID of the patient but a number assigned in the creation of the database. This number is vital for creating the algorithm, as it will be used to properly manage the presence of numerous entries in the dataset for the same patient.

  • Second column: In this column, you will assign the gold standard that the algorithm must recognize with the information abaliable in the dataframe. In other words, you will give a class to each entry of the dataframe. We strongly recommend using a number code to identify each class and not the string. That is to say, if there are two classes, let’s say “Benning” and “Malignant,” instead of writing in this Second column “Benning” or “Malignant,” we could assign the code number 0 to the Entries corresponding to “Benning,” and the code number 1 to entries corresponding to “Malignant,”

  • Third column: In this column, you will assign a specific characteristic to the entry that will be use for training the algorithm. This characteristic can be either a string or a number and it may be a continuous or discrete variable. It is important to take into account that the column cannot have empty entries.

In fact, you can have as many “third columns” as you want. That is to say, you can include as many characteristic columns to the algorithm as you wish. The only crucial aspect is that all of them should fulfill the requirements mentioned above

However, it is crucial that when you build your CSV file you remember the name that you assigned for each of the columns described above, as the Hippocrates form will ask you to identify the name of the columns that will be used to build the algorithm. This is vital since your CSV file might have several columns that you don’t want the algorithm to take into account in the process so that you can select which characteristics will be used in the building process

Below you can find an example of a CSV file created for a data algorithm

In this particular case, as you may recognize, there are several images for the same patient, and there is a forth column that we used to remember the name for each class

Zip file

Once you have the CSV file organized as described, you must ZIP it together with the images into a .zip file. Here is vital to remember that the directories structure that you use to define the images path in the CSV must be the same that you use when zipping the files. In that sense the zip file, for our study case is structure as follows