Basic Usage Examples

This notebook demonstrates the most common usage patterns for the pranaam package. We’ll cover:

  1. Single name prediction

  2. Multiple names prediction

  3. Mixed cultural names analysis

Let’s start by importing pranaam:

[1]:
import pandas as pd

import pranaam

print(f"Pranaam version: {pranaam.__version__ if hasattr(pranaam, '__version__') else 'latest'}")
2026-01-21 19:31:28.055829: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
2026-01-21 19:31:28.096314: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2026-01-21 19:31:29.509831: I external/local_xla/xla/tsl/cuda/cudart_stub.cc:31] Could not find cuda drivers on your machine, GPU will not be used.
Pranaam version: 0.0.2

🔮 Single Name Prediction

The most basic use case is predicting religion for a single name. Pranaam supports both English and Hindi names:

[2]:
# English name prediction
result = pranaam.pred_rel("Shah Rukh Khan", lang="eng")
print("English name prediction:")
print(result)
print()
[01/21/26 19:31:29] INFO     pranaam - Downloading models from dataverse...
[01/21/26 19:31:32] INFO     pranaam - Downloaded file size: 145359487 bytes
[01/21/26 19:31:34] INFO     pranaam - Finished downloading models
                    INFO     pranaam - Loading eng model from
                             /home/runner/work/pranaam/pranaam/pranaam/model/eng_and_hindi_models_v2/eng_model.kera
                             s
                    INFO     pranaam - Loading eng model with tf-keras compatibility layer
2026-01-21 19:31:34.993819: E external/local_xla/xla/stream_executor/cuda/cuda_platform.cc:51] failed call to cuInit: INTERNAL: CUDA error: Failed call to cuInit: UNKNOWN ERROR (303)
English name prediction:
             name pred_label  pred_prob_muslim
0  Shah Rukh Khan     muslim              71.0

[3]:
# Hindi name prediction
result = pranaam.pred_rel("शाहरुख खान", lang="hin")
print("Hindi name prediction:")
print(result)
[01/21/26 19:31:36] INFO     pranaam - Loading hin model from
                             /home/runner/work/pranaam/pranaam/pranaam/model/eng_and_hindi_models_v2/hin_model.kera
                             s
                    INFO     pranaam - Loading hin model with tf-keras compatibility layer
Hindi name prediction:
         name pred_label  pred_prob_muslim
0  शाहरुख खान     muslim              72.0

📝 Multiple Names Prediction

Pranaam is optimized for batch processing. You can process multiple names at once for better performance:

[4]:
# List of English names
names = ["Shah Rukh Khan", "Amitabh Bachchan", "Salman Khan", "Akshay Kumar"]

result = pranaam.pred_rel(names, lang="eng")
print("Batch prediction results:")
print(result)
[01/21/26 19:31:38] INFO     pranaam - Loading eng model from
                             /home/runner/work/pranaam/pranaam/pranaam/model/eng_and_hindi_models_v2/eng_model.kera
                             s
                    INFO     pranaam - Loading eng model with tf-keras compatibility layer
Batch prediction results:
               name  pred_label  pred_prob_muslim
0    Shah Rukh Khan      muslim              71.0
1  Amitabh Bachchan  not-muslim              31.0
2       Salman Khan      muslim              73.0
3      Akshay Kumar  not-muslim              27.0

🌍 Mixed Cultural Names Analysis

Let’s analyze a diverse set of names and format the output nicely to understand the predictions and confidence levels:

[5]:
diverse_names = [
    "Mohammed Ali",
    "Priya Sharma",
    "Fatima Khan",
    "Raj Patel",
    "John Smith",
]

result = pranaam.pred_rel(diverse_names, lang="eng")

print("Mixed Cultural Names Analysis")
print("=" * 45)
print(f"{'Name':<18} | {'Prediction':<10} | {'Confidence'}")
print("-" * 45)

for _, row in result.iterrows():
    print(f"{row['name']:<18} | {row['pred_label']:<10} | {row['pred_prob_muslim']:>6.1f}%")
Mixed Cultural Names Analysis
=============================================
Name               | Prediction | Confidence
---------------------------------------------
Mohammed Ali       | muslim     |   73.0%
Priya Sharma       | not-muslim |   27.0%
Fatima Khan        | muslim     |   73.0%
Raj Patel          | not-muslim |   35.0%
John Smith         | not-muslim |   37.0%

Understanding the Results

The pranaam package returns a pandas DataFrame with three columns:

  • ``name``: The input name

  • ``pred_label``: Either “muslim” or “not-muslim”

  • ``pred_prob_muslim``: Confidence percentage for muslim prediction

Interpreting Confidence Scores:

  • High scores (>90%): Strong confidence the name is Muslim

  • Low scores (<10%): Strong confidence the name is NOT Muslim

  • Medium scores (40-60%): Less certain predictions

Let’s visualize the confidence distribution:

[6]:
# Calculate actual confidence (distance from 50%)
result['confidence_score'] = result['pred_prob_muslim'].apply(
    lambda x: max(x, 100 - x)
)

# Categorize confidence levels
result['confidence_level'] = pd.cut(
    result['confidence_score'],
    bins=[0, 70, 90, 100],
    labels=['Low', 'Medium', 'High']
)

print("Confidence Analysis:")
print(result[['name', 'pred_label', 'confidence_score', 'confidence_level']])

print("\nConfidence Level Distribution:")
print(result['confidence_level'].value_counts())
Confidence Analysis:
           name  pred_label  confidence_score confidence_level
0  Mohammed Ali      muslim              73.0           Medium
1  Priya Sharma  not-muslim              73.0           Medium
2   Fatima Khan      muslim              73.0           Medium
3     Raj Patel  not-muslim              65.0              Low
4    John Smith  not-muslim              63.0              Low

Confidence Level Distribution:
confidence_level
Medium    3
Low       2
High      0
Name: count, dtype: int64

Next Steps

Now that you understand the basics, you can explore:

Key Takeaways

✅ Pranaam supports both single names and batch processing
✅ Works with English (lang="eng") and Hindi (lang="hin") names
✅ Returns structured pandas DataFrame with predictions and confidence
✅ Higher confidence scores indicate more reliable predictions
✅ Batch processing is more efficient for multiple names