Share via

Document AI table confidence

Herson Ian Moneda 60 Reputation points
Apr 24, 2025, 10:18 AM

Hi,

I would like to know if we can extract or get the confidence value of the table. I can get the confidence value of the fields but I had a hard time figuring out if we can get the confidence of each table rows.

User's image

I used this code but it will only get the confidence of the fields string.

            foreach (AnalyzedDocument document in result.Documents)

            {

                Console.WriteLine($"Document of type: {document.DocumentType}");

                foreach (KeyValuePair<string, DocumentField> fieldKvp in document.Fields)

                {

                    string fieldName = fieldKvp.Key;

                    DocumentField field = fieldKvp.Value;

                    Console.WriteLine($"Field '{fieldName}': ");

                    Console.WriteLine($"  Content: '{field.Content}'");

                    Console.WriteLine($"  Confidence: '{field.Confidence}'");

                }

            }
Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
2,024 questions
0 comments No comments
{count} votes

Accepted answer
  1. Prashanth Veeragoni 3,955 Reputation points Microsoft External Staff
    Apr 24, 2025, 3:10 PM

    Hi Herson Ian Moneda,

    Yes, you're on the right track using the DocumentField.Confidence property, but if you're working with tables (especially rows within a table), Azure Document Intelligence (formerly Form Recognizer) handles tables as a structured set of DocumentTable objects.

    To get row-level confidence, you’ll need to access the DocumentTable, then go down to each cell, where you can get the Confidence per cell, and from that, aggregate to estimate the confidence for each row.

    How to get row-level table confidence

    Here’s how you can do it:

    foreach (AnalyzedDocument document in result.Documents)
    {
        Console.WriteLine($"Document Type: {document.DocumentType}");
    
        foreach (DocumentTable table in document.Tables)
        {
            Console.WriteLine("Processing a table...");
            
            int rowIndex = 0;
            foreach (var row in table.Cells.GroupBy(c => c.RowIndex))
            {
                double rowConfidence = row.Average(c => c.Confidence); // Averaging all cell confidences in the row
                Console.WriteLine($"Row {rowIndex}: Confidence = {rowConfidence:P2}");
    
                foreach (var cell in row)
                {
                    Console.WriteLine($"  Cell ({cell.RowIndex},{cell.ColumnIndex}): '{cell.Content}', Confidence: {cell.Confidence:P2}");
                }
                rowIndex++;
            }
        }
    }
    

    Explanation:

    ·       document.Tables accesses all tables in a document.

    ·       table.Cells gives all the cells, each of which has:

    o   RowIndex and ColumnIndex

    o   Content

    o   Confidence

    ·       Cells are grouped by RowIndex to simulate rows.

    ·       Confidence for a row is computed as the average confidence of its cells (you can also take min/max/median based on your quality strategy).

    Notes:

    ·       This method does not give a single "row confidence" field natively, but it's the best approximation.

    ·       If you’re using Azure.AI.FormRecognizer.DocumentAnalysis, make sure you’re using v3.2+ SDK to access all these properties.

    Hope this helps. Do let me know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    Thank you!

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.