Downloads · 30 days
0
ckcl/mexc_price_model
mexc_price_model is a machine learning model from ckcl. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for adapter-transformers. The card lists the license as mit.
https://huggingface.co/ckcl/mexcpricemodel/blob/main/CNREADME.md
Downloads · 30 days
0
Access
Public
Updated Sep 28, 2024
Repo size
3.4 MB
Likes
1
Public
Click a slice to open those files.
.pth3.4 MB · 100%
From the Hugging Face model README
https://huggingface.co/ckcl/mexc_price_model/blob/main/CN_README.md
This model is a custom Transformer model designed to predict MEXC contract prices. It consists of an embedding layer followed by multiple Transformer encoder layers, and a fully connected layer at the end to produce the output.
The model was trained on historical MEXC contract transaction data. The features include open, close, high, low prices, volume, amount, real open, real close, real high, real low prices, and moving averages.
To use this model for prediction, follow these steps:
Load the model and configuration:
import torch
import torch.nn as nn
from transformers import AutoConfig
class CustomTransformerModel(nn.Module):
def __init__(self, config):
super(CustomTransformerModel, self).__init__()
self.embedding = nn.Linear(config.input_dim, config.model_dim)
self.encoder_layer = nn.TransformerEncoderLayer(d_model=config.model_dim, nhead=config.num_heads, batch_first=True)
self.transformer_encoder = nn.TransformerEncoder(self.encoder_layer, num_layers=config.num_layers)
self.fc = nn.Linear(config.model_dim, config.output_dim)
def forward(self, src):
src = self.embedding(src)
output = self.transformer_encoder(src)
output = self.fc(output[:, -1, :])
return output
config = AutoConfig.from_pretrained("your-username/mexc_price_model", config_file_name="BTC_USDT.json")
model = CustomTransformerModel(config)
model.load_state_dict(torch.load("model_repo/mexc_price.pth"))
model.eval()
Prepare input data and make predictions:
import numpy as np
from sklearn.preprocessing import StandardScaler
new_data = np.array([
[1.727087e+09, 63483.9, 63426.2, 63483.9, 63411.6, 1193897.0, 7.575486e+06, 63483.8, 63426.2, 63483.9, 63411.6, 0.00, 0.0, 0.0]
])
scaler = StandardScaler()
new_data_scaled = scaler.fit_transform(new_data)
input_tensor = torch.tensor(new_data_scaled, dtype=torch.float32).unsqueeze(1)
with torch.no_grad():
prediction = model(input_tensor)
predicted_value = prediction.squeeze().item()
print(f"Predicted Value: {predicted_value}")
This model is licensed under the MIT License.