Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token trend action #14

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions awesome-giza-actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ A curated list of models and algorithms built with [Giza Actions SDK](https://ac
### Basics
- [MNIST Classification with Giza Actions](https://github.com/gizatechxyz/actions-sdk/blob/main/examples/verifiable_mnist/verifiable_mnist.ipynb)

## DeFi
- [Binary Liquidation Prediction in Aave v2 & v3](Aave_Liquidation_Model)
- [Predicting Cryptocurrency Token Trends with Giza: An End-to-End Machine Learning Approach](trend_token_prediction)

## Learn the basics

Familiarize yourself with Giza Actions SDK. How to build your own ML workflow and perform verifiableinference.
Expand Down
Empty file.
19 changes: 19 additions & 0 deletions awesome-giza-actions/trend_token_prediction/download_proof.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import requests
from giza import API_HOST

MODEL_ID = None # Update with your model ID
VERSION_ID = None # Update with your version ID
DEPLOYMENT_ID = None # Update with your deployment id
REQUEST_ID = None # Update with your request id
API_KEY = None # Update with your API key

url = f"{API_HOST}/api/v1/models/{MODEL_ID}/versions/{VERSION_ID}/deployments/{DEPLOYMENT_ID}/proofs/{REQUEST_ID}:download"

headers = {"X-API-KEY": API_KEY}

d_url = requests.get(url, headers=headers).json()["download_url"]

proof = requests.get(d_url)

with open("zk.proof", "wb") as f:
f.write(proof.content)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from giza_actions.action import Action, action
from giza_actions.model import GizaModel
from giza_actions.task import task
import polars as pl
import numpy as np
import torch


@task(name="Prediction with Cairo")
def prediction(X_test, model):
(result, request_id) = model.predict(
input_feed={"input_feed": X_test},
verifiable=True,
output_dtype="arr_fixed_point",
)
return result, request_id


@action(name="Execution: Prediction with Cairo", log_prints=True)
def execution():
model = GizaModel(id=293, version=1)
df = pl.read_csv("./example_token_trend.csv")
model_input = df.to_numpy().astype(np.float32)
(result, request_id) = prediction(model_input, model)
return result, request_id


(result, request_id) = execution()
print(f"Result: {result}, Request ID: {request_id}")
Binary file not shown.
Loading