ckcl
/

Adapters
Safetensors
prediction
ckcl commited on
Commit
d5c7569
·
verified ·
1 Parent(s): 1b1f699

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +81 -3
README.md CHANGED
@@ -1,3 +1,81 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Custom Transformer Model for MEXC Price Prediction
2
+
3
+ ## Model Description
4
+
5
+ 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.
6
+
7
+ ## Model Architecture
8
+
9
+ - **Input Dimension:** 13
10
+ - **Model Dimension:** 64
11
+ - **Number of Heads:** 8
12
+ - **Number of Layers:** 2
13
+ - **Output Dimension:** 1
14
+
15
+ ## Training Data
16
+
17
+ 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.
18
+
19
+ ## Training Details
20
+
21
+ - **Optimizer:** Adam
22
+ - **Learning Rate:** 0.001
23
+ - **Loss Function:** Mean Squared Error (MSE)
24
+ - **Batch Size:** 32
25
+ - **Number of Epochs:** 50
26
+
27
+ ## Usage
28
+
29
+ To use this model for prediction, follow these steps:
30
+
31
+ 1. Load the model and configuration:
32
+
33
+ ```python
34
+ import torch
35
+ import torch.nn as nn
36
+ from transformers import AutoConfig
37
+
38
+ class CustomTransformerModel(nn.Module):
39
+ def __init__(self, config):
40
+ super(CustomTransformerModel, self).__init__()
41
+ self.embedding = nn.Linear(config.input_dim, config.model_dim)
42
+ self.encoder_layer = nn.TransformerEncoderLayer(d_model=config.model_dim, nhead=config.num_heads, batch_first=True)
43
+ self.transformer_encoder = nn.TransformerEncoder(self.encoder_layer, num_layers=config.num_layers)
44
+ self.fc = nn.Linear(config.model_dim, config.output_dim)
45
+
46
+ def forward(self, src):
47
+ src = self.embedding(src)
48
+ output = self.transformer_encoder(src)
49
+ output = self.fc(output[:, -1, :])
50
+ return output
51
+
52
+ config = AutoConfig.from_pretrained("your-username/mexc_price_model", config_file_name="BTC_USDT.json")
53
+ model = CustomTransformerModel(config)
54
+ model.load_state_dict(torch.load("model_repo/mexc_price.pth"))
55
+ model.eval()
56
+ ```
57
+
58
+ 2. Prepare input data and make predictions:
59
+
60
+ ```python
61
+ import numpy as np
62
+ from sklearn.preprocessing import StandardScaler
63
+
64
+ new_data = np.array([
65
+ [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]
66
+ ])
67
+
68
+ scaler = StandardScaler()
69
+ new_data_scaled = scaler.fit_transform(new_data)
70
+ input_tensor = torch.tensor(new_data_scaled, dtype=torch.float32).unsqueeze(1)
71
+
72
+ with torch.no_grad():
73
+ prediction = model(input_tensor)
74
+
75
+ predicted_value = prediction.squeeze().item()
76
+ print(f"Predicted Value: {predicted_value}")
77
+ ```
78
+
79
+ ## License
80
+
81
+ This model is licensed under the [MIT License](LICENSE).