Code Examples

Ready-to-use examples for common statistical analyses. Copy, paste, and adapt to your needs.

Quick Start Examples

Copy these examples directly into your AI assistant

📈 Linear Regression Analysis

Most Popular

Predict sales based on marketing spend with automatic feature selection and diagnostics.

# Use MCP Analytics to run linear regression
mcp.tools_run(
  tool_name="linear_regression",
  taskList={
    "inputs": {
      "dataset": "https://your-data-url.com/sales.csv",
      "userContext": {
        "objective": "Predict sales based on marketing spend",
        "company": "Your Company"
      },
      "target": "sales_amount",
      "features": ["tv_spend", "digital_spend", "print_spend"]
    }
  },
  generate_insights=true
)

📤 Secure Dataset Upload

Encrypted

Upload and encrypt your local datasets for analysis.

# Step 1: Generate upload token
token_info = mcp.datasets.upload(
  expires_in=1800,  # 30 minutes
  metadata={
    "description": "Q4 2024 Sales Data",
    "type": "sales"
  }
)

# Step 2: Use the provided curl command to upload
# Step 3: Analyze your encrypted dataset
mcp.tools_run(
  tool_name="data_profiling",
  taskList={
    "inputs": {
      "dataset": f"uuid://{token_info.uuid}:{token_info.key}"
    }
  }
)

📊 ARIMA Time Series Forecasting

Advanced

Forecast future values with seasonal patterns and confidence intervals.

mcp.tools_run(
  tool_name="arima_forecast",
  taskList={
    "inputs": {
      "dataset": "monthly_revenue.csv",
      "userContext": {
        "objective": "Forecast next 6 months revenue with seasonality"
      },
      "target": "revenue",
      "date_column": "month",
      "periods": 6,
      "seasonal": true,
      "confidence": 0.95
    }
  }
)

🔍 Semantic Report Search

AI-Powered

Find insights across all your analyses using natural language.

# Search for related analyses
results = mcp.reports.search(
  semantic_query="customer churn prediction models with high accuracy",
  threshold=0.8,
  date_from="2024-01-01",
  limit=5
)

# Get full report details
report = mcp.reports.search(
  job_ids=[results[0].id],
  include_data=true,
  keys=["model_metrics", "feature_importance"]
)

# Generate shareable link
share_url = mcp.reports.view(
  processing_id=results[0].id,
  expires_in=86400  # 24 hours
)

Complete Workflows

End-to-end examples for common use cases

Customer Segmentation

Complete workflow for customer segmentation using K-means clustering.

  1. Upload customer data with demographics
  2. Run data profiling to understand distributions
  3. Apply K-means clustering
  4. Analyze segment characteristics
  5. Generate shareable report
View Full Example

A/B Test Analysis

Statistical significance testing for conversion rate optimization.

  1. Import experiment data
  2. Check sample size requirements
  3. Run t-test or chi-square test
  4. Calculate confidence intervals
  5. Generate decision report
View Full Example

Revenue Forecasting

Build accurate revenue forecasts with seasonal adjustments.

  1. Load historical revenue data
  2. Detect seasonal patterns
  3. Fit ARIMA model
  4. Generate forecasts with intervals
  5. Create presentation-ready visuals
View Full Example

Natural Language Examples

Ask your AI assistant in plain English

Natural Language Examples
User: "Analyze the correlation between all variables in my sales dataset"
User: "Run a regression to predict customer lifetime value based on purchase history"
User: "Find all my analyses from last month about customer segmentation"
User: "Upload my CSV file and create a data profile report"
User: "Compare Ridge and Lasso regression on this dataset"
User: "Forecast next quarter's revenue with 95% confidence intervals"

Start with These Examples

Copy any example and start analyzing your data immediately.