Predictrix

Welcome to Predictrix, a real-time user behavior analysis application designed to simulate and analyze user interaction data.

The Goal Of This Project Is To Showcase My Expertise In :

This project includes:

What Does Predictrix Do?

Predictrix is a comprehensive user behavior analysis tool designed to simulate, analyze, and predict user interactions in real-time. The key features of Predictrix include:

1. Python Script to Simulate User Interaction Data

The Predictrix project starts by simulating user interaction logs using a Python script. The script creates random logs to mimic typical user actions like adding items to the cart, logging in, viewing pages, and more.

How Data Gets Into Splunk - Detailed Flow

Python Script Code


# Python code example

import random
import json
import requests

def generate_user_interaction():
    actions = ["Add to Cart", "Login", "Page View"]
    user_interaction = {
        "user_id": random.randint(1, 1000),
        "event": random.choice(actions),
        "device": random.choice(["Desktop", "Mobile", "Tablet"]),
        "location": random.choice(["USA", "Canada", "UK"]),
        "page": random.choice(["Home", "Product", "Checkout"]),
        "timestamp": random.randint(1609459200, 1640995200)
    }
    return json.dumps(user_interaction)

def send_to_splunk(data):
    url = "https://127.0.0.1:8088/services/collector"
    headers = {"Authorization": "Splunk YOUR_SPLUNK_HEC_TOKEN"}
    response = requests.post(url, headers=headers, data=data)
    return response.status_code

if __name__ == "__main__":
    for _ in range(10):
        log = generate_user_interaction()
        status = send_to_splunk(log)
        print(f"Sent log with status code: {status}")

2. Predictive Insights

Using Splunk MLTK, we predict user behaviors based on interaction history.

The Predictrix platform leverages Splunk's Machine Learning Toolkit (MLTK) to create a predictive model that forecasts user purchase completion based on their interactions and behaviors. The following details highlight the model setup, data processing, and key configurations:

Purchase Likelihood Pie Chart

3. Splunk Dashboards

Interactive dashboards visualize user engagement, login activity, and more.

  • Counts the number of events grouped by the location field in the predictrix index.
    index=predictrix | stats count by location
  • Dashboard Example 1

  • Counts the number of events grouped by the page field and sorts the results in descending order of the count.
    index=predictrix | stats count by page | sort - count
  • Dashboard Example 2

  • Applies a machine learning model (purchase_prediction_mode), evaluates whether a user is likely to purchase or not, and counts events by prediction categories (Likely to Purchase or Not Likely to Purchase).
    index=predictrix | apply purchase_prediction_mode 
                     | eval predicted_purchase=if('predicted(purchase)' == 1.0, "Likely to Purchase", 
            "Not Likely to Purchase")
                     | stats count by predicted_purchase
                
  • Dashboard Example 2

  • Creates a time chart with a 1-hour span, displaying the count of events grouped by the event field over time.
    index=predictrix | timechart span=1h count by event
  • Dashboard Example 2

    4. Real-Time Alerts

    Set up this alert in Splunk to track interactions on the "Checkout" page

  • Condition: The alert will trigger whenever there is at least one event where a user interacts with the "Checkout" page.

  • Search Query: The query looks for events in the predictrix index where the page is identified as "Checkout." It then extracts details like the device used, the type of event, the user's location, the page, the timestamp, and the user ID.

  • Action: When the alert is triggered, it adds the alert to the "Triggered Alerts" list and sends a notification via a webhook.
  • index=predictrix | search page="Checkout"
                     | table device, event, location, page, timestamp, user_id

    This alert helps monitor user interactions on the checkout page, and the data can be used for tracking behavior, troubleshooting, or analytics purposes.

    Contact Me