Python Client Example
Initialize the client¶
In [ ]:
Copied!
import crowdcent_challenge as cc
import polars as pl
import numpy as np
client = cc.ChallengeClient(
challenge_slug="hyperliquid-ranking",
api_key="hD5EB4pf.KvY8281Kz4igdNBCK7P0RL6tG6J8EaAU",
base_url="http://localhost:8080/api",
)
import crowdcent_challenge as cc
import polars as pl
import numpy as np
client = cc.ChallengeClient(
challenge_slug="hyperliquid-ranking",
api_key="hD5EB4pf.KvY8281Kz4igdNBCK7P0RL6tG6J8EaAU",
base_url="http://localhost:8080/api",
)
Get challenge and training datasets details¶
In [ ]:
Copied!
client.get_challenge()
client.get_challenge()
In [ ]:
Copied!
client.list_training_datasets()
client.list_training_datasets()
Download current inference data¶
In [ ]:
Copied!
client.download_inference_data(
release_date="current", dest_path="inference_data.parquet"
)
client.download_inference_data(
release_date="current", dest_path="inference_data.parquet"
)
In [ ]:
Copied!
# Read in the inference data, in this case, just a universe
inference_data = pl.read_parquet("inference_data.parquet")
inference_data.head()
# Read in the inference data, in this case, just a universe
inference_data = pl.read_parquet("inference_data.parquet")
inference_data.head()
Submit predictions¶
In [ ]:
Copied!
# Add prediction columns with random float values for demonstration
# Replace this with your actual prediction logic
inference_data = inference_data.with_columns(
[
pl.Series("pred_10d", np.random.random(len(inference_data))).cast(pl.Float64),
pl.Series("pred_30d", np.random.random(len(inference_data))).cast(pl.Float64),
]
)
# You can save this modified dataframe if needed
inference_data.write_parquet("inference_data_with_predictions.parquet")
# Display the first few rows to verify the new columns
print("Inference data with prediction columns:")
inference_data.head()
# Add prediction columns with random float values for demonstration
# Replace this with your actual prediction logic
inference_data = inference_data.with_columns(
[
pl.Series("pred_10d", np.random.random(len(inference_data))).cast(pl.Float64),
pl.Series("pred_30d", np.random.random(len(inference_data))).cast(pl.Float64),
]
)
# You can save this modified dataframe if needed
inference_data.write_parquet("inference_data_with_predictions.parquet")
# Display the first few rows to verify the new columns
print("Inference data with prediction columns:")
inference_data.head()
In [ ]:
Copied!
client.submit_predictions(file_path="inference_data_with_predictions.parquet", slot=1)
client.submit_predictions(file_path="inference_data_with_predictions.parquet", slot=1)
In [ ]:
Copied!
for slot in range(1, 6):
client.submit_predictions(
file_path="inference_data_with_predictions.parquet", slot=slot
)
for slot in range(1, 6):
client.submit_predictions(
file_path="inference_data_with_predictions.parquet", slot=slot
)
Meta-model¶
In [ ]:
Copied!
client.download_meta_model(dest_path="meta_model.parquet")
pl.read_parquet("meta_model.parquet").head()
client.download_meta_model(dest_path="meta_model.parquet")
pl.read_parquet("meta_model.parquet").head()