UMAP Dimensionality Reduction API

This is a high-performance dimensionality reduction microservice using UMAP (Uniform Manifold Approximation and Projection). It provides an efficient way to reduce high-dimensional data to 2D or 3D representations, making it easier to visualize and analyze complex datasets.

When to Use This Service

Common Use Cases

How to Use

Send a POST request to this endpoint with your data to use the API. The request should include an array of embeddings and optional configuration parameters.

Basic Example:

fetch("https://ejfox-umap.web.val.run/", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        embeddings: [[1,2,3], [4,5,6], [7,8,9]],
        config: { nNeighbors: 15, minDist: 0.1, spread: 1.0 }
    })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
        

Curl Example:

        curl -X POST -H "Content-Type: application/json" -d '{"embeddings": [[1,2,3], [4,5,6], [7,8,9]], "config": { "nNeighbors": 15, "minDist": 0.1, "spread": 1.0 }}' https://ejfox-umap.web.val.run/
        

Example with OpenAI Embeddings:

This example shows how to use the UMAP service with OpenAI embeddings:

// First, generate embeddings using OpenAI API
import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();

async function getEmbeddings(texts) {
    const response = await openai.embeddings.create({
        model: "text-embedding-ada-002",
        input: texts,
    });
    return response.data.map(item => item.embedding);
}

// Then, use these embeddings with the UMAP service
const texts = ["Hello world", "OpenAI is amazing", "UMAP reduces dimensions"];
const embeddings = await getEmbeddings(texts);

fetch("/", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
        embeddings: embeddings,
        config: { nNeighbors: 15, minDist: 0.1, spread: 1.0 }
    })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
        

Live Demo

Click the button below to see a live demo with random data:

View source: Val Town