LatticaAI Documentation
  • Welcome to LatticaAI
  • Conceptual Guide
  • Architecture Overview
    • Management Client
    • Query Client
  • Platform Workflows
    • Account Management
    • Model Management
    • User Access Management
    • Query Submission
    • Credit Management
    • Worker Management
  • How-To Guides
    • Client Installation
      • How-To: Install Management Client
      • How-To: Install Query Client
    • Model Lifecycle
      • How-To: Deploy AI model
      • How-To: Modify AI Model Settings
    • Access Control
      • How-To: Create User Access Token
      • How-To: Modify User Access Token Setting
      • How-To: Remove Token's Assignment
      • How-To: Assign Token to Model
      • How-To: See List of Tokens
    • Resource Management
      • How-To: Start Worker
      • How-To: Stop Worker
      • How-To: Monitor Worker Performance
    • Secure Query Processing
      • How To: Upload Evaluation Key
      • How-To: Encrypt Input Message
      • How To: Execute Query
      • How-To: Decrypt Output Data
      • How-To: Encrypt, Execute, and Decrypt in One Step
    • Account and Finance Operations
      • How-To: View Payment Transaction History
      • How-To: Update Account Information
      • How-To: View Credit Balance and Add Credit to Your Account
      • How-To: Monitor Balance and Usage
  • Demo Tutorials
    • Image Sharpening with LatticaAI Demo Tutorial
    • Sentiment Analysis with LatticaAI Demo Tutorial
    • Health Analysis with LatticaAI Demo Tutorial
    • Digit Recognition with LatticaAI Demo Tutorial
    • Zooming Into Each Step of Demo Run with LatticaAI flow
Powered by GitBook
On this page
  • Overview of the Model
  • Achieving Full Privacy with LatticaAI

Was this helpful?

  1. Demo Tutorials

Health Analysis with LatticaAI Demo Tutorial

PreviousSentiment Analysis with LatticaAI Demo TutorialNextDigit Recognition with LatticaAI Demo Tutorial

Last updated 2 months ago

Was this helpful?

Overview of the Model

Our Health Analysis model is trained on the . This dataset is designed to facilitate the application of machine learning to the medical field, aiding physicians by automating disease diagnosis based on symptoms.

The dataset consists of 131 binary columns representing different symptoms that a person may experience, and maps symptoms to 41 different diseases, allowing classification based on input symptoms.

We trained multi-class logistic regression model, implemented the equivalent fully homomorphic model and deployed it to our cloud service for secure inference.

  • Input Format: binary vector of length 131.

  • Output: Probability vector of length 41 that represents the possible diseases.

The equivalent pytorch code for the inference is:

import torch
import json
import numpy as np


# load the symptoms and diseases mappings
with open('symptoms.json', 'r') as f:
    symptoms = json.load(f)

with open('diseases.json', 'r') as f:
    diseases = json.load(f)

# load the coef matrix and intercept vector of the trained logistic regression model
W = np.load('coef.npy')  # shape (41,131)
b = np.load('intercept.npy')  # shape (41,)

# create binary vector of length 131, corresponding to the mapping symptoms.json
pt = torch.zeros(131, dtype=torch.float64)
pt[symptoms['Continuous Sneezing']] = 1
pt[symptoms['Shivering']] = 1
pt[symptoms['Chills']] = 1
pt[symptoms['Watering From Eyes']] = 1

# calculate the logistic regression prediction
res = torch.nn.functional.softmax(pt @ W.T + b, dim=0)

# the predicted disease according to the mapping diseases.json
disease = diseases[res.argmax().item()]
print(f"Predicted disease: {disease}")

Achieving Full Privacy with LatticaAI

from lattica_query.auth import get_demo_token
from lattica_query.lattica_query_client import QueryClient

model_id = "healthPrediction"
my_token = get_demo_token(model_id)

client = QueryClient(my_token)

context, secret_key, client_blocks, = client.generate_key()

# `pt` and `res` are torch.Tensor, same as in the plain example above
pt = torch.randint(0, 2, (131,), dtype=torch.float64)

res = client.run_query(context, secret_key, pt, client_blocks)
import { getDemoToken, LatticaQueryClient } from '@Lattica-ai/lattica-query-client';

const modelId = "healthPrediction"
const token = await getDemoToken(modelId);

const client = new LatticaQueryClient(myToken);

await client.init();

const pt = [1, 1, 0, , 0, 1,...];
const result = await client.runQuery(pt);

First our client package

See our for a detailed explanation of each step in this flow. To use the image sharpening model use the healthPrediction model ID

step-by-step guide
Disease Prediction Kaggle dataset
install
3KB
symptoms.json
List of 131 possible symptoms
685B
diseases.json
List of 41 disease
42KB
coef.npy
456B
intercept.npy