Python SDK for Sematryx - AI-powered optimization that explains itself
Project description
Sematryx Python SDK
Official Python SDK for Sematryx - AI-powered optimization that explains itself.
Installation
pip install sematryx
Quick Start
from sematryx import Sematryx
client = Sematryx(api_key="sk-your-api-key")
# Simple optimization
result = client.optimize(
objective="minimize",
variables=[
{"name": "x", "bounds": (-5, 5)},
{"name": "y", "bounds": (-5, 5)},
],
objective_function="x**2 + y**2",
)
print(f"Solution: {result.solution}") # {'x': 0.0, 'y': 0.0}
print(f"Explanation: {result.explanation}")
Features
- Simple API - One function call to optimize
- Explainable Results - Understand why the optimizer made its decisions
- Audit Trails - Full traceability for regulated industries
- Private Learning - Your optimizations improve over time
- Domain Libraries - Pre-built for finance, healthcare, supply chain
CLI Usage
# Install
pip install sematryx
# Set API key
export SEMATRYX_API_KEY=sk-your-api-key
# Run optimization
sematryx optimize "x**2 + y**2" --bounds '{"x": [-5, 5], "y": [-5, 5]}'
# Check usage
sematryx usage
Async Support
from sematryx import AsyncSematryx
async with AsyncSematryx(api_key="sk-...") as client:
result = await client.optimize(
objective="minimize",
variables=[{"name": "x", "bounds": (-5, 5)}],
objective_function="x**2",
)
Portfolio Optimization
result = client.optimize_portfolio(
assets=["AAPL", "GOOGL", "MSFT", "AMZN"],
returns=[0.12, 0.10, 0.08, 0.15],
covariance=[...], # 4x4 covariance matrix
target_return=0.10,
max_position=0.4,
explanation_level=3,
)
print(result.solution) # {'AAPL': 0.25, 'GOOGL': 0.20, ...}
print(result.explanation) # "Allocated to maximize Sharpe ratio..."
Private Learning Store
Your optimizations improve over time:
result = client.optimize(
...,
learning={
"read_from_private": True, # Learn from your past optimizations
"write_to_private": True, # Store this result for future learning
}
)
Documentation
Full documentation at sematryx.com/docs
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sematryx-0.1.0.tar.gz
(9.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
sematryx-0.1.0-py3-none-any.whl
(11.1 kB
view details)
File details
Details for the file sematryx-0.1.0.tar.gz.
File metadata
- Download URL: sematryx-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
457eaaabf4db3fadc6f18e77b7ae346bc6b161425ecbf3e4ea6d8f5b164c6053
|
|
| MD5 |
791c734dbe4023d5a35b53a798d0cb53
|
|
| BLAKE2b-256 |
6396ad45e4af11fcca35c8369d78f3f04bd41b3c0ee89e783ef939cda5026dc2
|
File details
Details for the file sematryx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sematryx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f08acbc1b4a0e514fdf4078d3b2df29c4b0e6b70237208da71dce4f6fde1734f
|
|
| MD5 |
94c00d0f3c51f0df807c714f877e39e7
|
|
| BLAKE2b-256 |
ad1e579d5698a8a91437a59d30266fe78f5b13e8cceab6ac0782c0203f04a749
|