ModelLoader
Loader class for interacting with the Minio Object Storage API.
Source code in make_us_rich/serving/model_loader.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
_add_model_to_session_models(currency, compare)
Adds a new model to the model session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
currency |
str
|
Currency used in the model. |
required |
compare |
str
|
Compare used in the model. |
required |
Returns:
Type | Description |
---|---|
str
|
Source code in make_us_rich/serving/model_loader.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|
_check_model_exists_in_session(model_name)
Checks if the model exists in the current session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name |
str
|
Name of the model. |
required |
Returns:
Type | Description |
---|---|
bool
|
Source code in make_us_rich/serving/model_loader.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
_download_files(currency, compare)
Downloads model and features engineering files from Minio.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
currency |
str
|
Currency used in the model. |
required |
compare |
str
|
Compare used in the model. |
required |
Source code in make_us_rich/serving/model_loader.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
_get_list_of_available_models()
Looks for available models in the Minio bucket based on the date.
Returns:
Type | Description |
---|---|
List[str]
|
List of available models. |
Source code in make_us_rich/serving/model_loader.py
123 124 125 126 127 128 129 130 131 132 133 |
|
_get_models_files_path(currency, compare)
Returns the path to the files in models directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
currency |
str
|
Currency used in the model. |
required |
compare |
str
|
Compare used in the model. |
required |
Returns:
Type | Description |
---|---|
str
|
Path to the model files. |
Source code in make_us_rich/serving/model_loader.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
_makedir(currency, compare)
Creates a directory for the model files if it doesn't exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
currency |
str
|
Currency used in the model. |
required |
compare |
str
|
Compare used in the model. |
required |
Source code in make_us_rich/serving/model_loader.py
85 86 87 88 89 90 91 92 93 94 95 96 |
|
get_predictions(model_name, sample)
Gets the predictions from the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name |
str
|
Name of the model. |
required |
sample |
pd.DataFrame
|
Sample to predict. |
required |
Returns:
Type | Description |
---|---|
float
|
Predicted value. |
Source code in make_us_rich/serving/model_loader.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
update_date()
Updates the date of the loader.
Source code in make_us_rich/serving/model_loader.py
47 48 49 50 51 |
|
update_model_files()
Updates the model files in the serving models directory.
Source code in make_us_rich/serving/model_loader.py
54 55 56 57 58 59 60 61 |
|
OnnxModel
Source code in make_us_rich/serving/model.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
_create_descaler()
Creates a descaler.
Returns:
Type | Description |
---|---|
MinMaxScaler
|
Source code in make_us_rich/serving/model.py
49 50 51 52 53 54 55 56 57 58 59 |
|
_descaling_sample(sample)
Descalings the sample.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample |
Sample to be descaled. |
required |
Returns:
Type | Description |
---|---|
float
|
Descaled sample. |
Source code in make_us_rich/serving/model.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
_load_scaler()
Loads the scaler from the model files.
Returns:
Type | Description |
---|---|
MinMaxScaler
|
Source code in make_us_rich/serving/model.py
80 81 82 83 84 85 86 87 88 89 |
|
_preprocessing_sample(sample)
Preprocesses the input sample.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample |
pd.DataFrame
|
Input sample. |
required |
Returns:
Type | Description |
---|---|
torch.tensor
|
Preprocessed sample. |
Source code in make_us_rich/serving/model.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
predict(sample)
Predicts the close price based on the input sample.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample |
pd.DataFrame
|
Input sample. |
required |
Returns:
Type | Description |
---|---|
float
|
Predicted close price. |
Source code in make_us_rich/serving/model.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|