Asif Ahmad commited on
Commit
a21a06f
·
1 Parent(s): 0a6a1d7

Create xgb_training.py

Browse files
Files changed (1) hide show
  1. xgb_training.py +42 -0
xgb_training.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # developer: Taoshidev
2
+ # Copyright © 2023 Taoshi, LLC
3
+
4
+ # developer: Taoshidev
5
+ # Copyright © 2023 Taoshi, LLC
6
+
7
+ import random
8
+
9
+ import numpy as np
10
+ from sklearn.preprocessing import MinMaxScaler
11
+
12
+ from mining_objects.xgb_mining_model import BaseMiningModel
13
+ from mining_objects.mining_utils import MiningUtils
14
+ from time_util.time_util import TimeUtil
15
+ from vali_objects.dataclasses.client_request import ClientRequest
16
+ from vali_config import ValiConfig
17
+
18
+ import bittensor as bt
19
+
20
+ # historical doesnt have timestamps
21
+ data_structure = MiningUtils.get_file("/runnable/historical_financial_data/data.pickle", True)
22
+ #data_structure = [data_structure[0][curr_iter:curr_iter+iter_add],
23
+ # data_structure[1][curr_iter:curr_iter+iter_add],
24
+ # data_structure[2][curr_iter:curr_iter+iter_add],
25
+ # data_structure[3][curr_iter:curr_iter+iter_add],
26
+ # data_structure[4][curr_iter:curr_iter+iter_add]]
27
+ print(len(data_structure[0]))
28
+ print("start", TimeUtil.millis_to_timestamp(data_structure[0][0]))
29
+ print("end", TimeUtil.millis_to_timestamp(data_structure[0][len(data_structure[0])-1]))
30
+ sds_ndarray = np.array(data_structure).T
31
+
32
+ scaler = MinMaxScaler(feature_range=(0, 1))
33
+
34
+ scaled_data = scaler.fit_transform(sds_ndarray)
35
+ scaled_data = scaled_data.T
36
+
37
+
38
+
39
+ # will iterate and prepare the dataset and train the model as provided
40
+ prep_dataset = BaseMiningModel.base_model_dataset(scaled_data)
41
+ base_mining_model = BaseMiningModel(len(prep_dataset.T)).set_model_dir('./mining_models/xgbTrain.model')
42
+ base_mining_model.train(prep_dataset)#, epochs=25)