virgo-modules 0.4.2__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of virgo-modules might be problematic. Click here for more details.
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/PKG-INFO +1 -1
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/setup.py +1 -1
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/edge_utils/edge_utils.py +5 -1
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/re_utils.py +20 -7
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/transformer_utils.py +41 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules.egg-info/PKG-INFO +1 -1
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/LICENSE +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/README.md +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/setup.cfg +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/__init__.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/__init__.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/aws_utils.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/backtester.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/edge_utils/__init__.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/edge_utils/conformal_utils.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/edge_utils/shap_utils.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/hmm_utils.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/pull_artifacts.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/ticketer_source.py +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules.egg-info/SOURCES.txt +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules.egg-info/dependency_links.txt +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules.egg-info/requires.txt +0 -0
- {virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules.egg-info/top_level.txt +0 -0
|
@@ -5,7 +5,7 @@ with open("virgo_app/README.md", "r") as f:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="virgo_modules",
|
|
8
|
-
version="0.4.
|
|
8
|
+
version="0.4.4",
|
|
9
9
|
description="data processing and statistical modeling using stock market data",
|
|
10
10
|
package_dir={"": "virgo_app"},
|
|
11
11
|
packages=find_packages(where="virgo_app"),
|
{virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/edge_utils/edge_utils.py
RENAMED
|
@@ -9,7 +9,7 @@ from feature_engine.imputation import MeanMedianImputer
|
|
|
9
9
|
from feature_engine.discretisation import EqualWidthDiscretiser
|
|
10
10
|
from feature_engine.datetime import DatetimeFeatures
|
|
11
11
|
|
|
12
|
-
from ..transformer_utils import VirgoWinsorizerFeature, InverseHyperbolicSine, FeaturesEntropy, FeatureSelector
|
|
12
|
+
from ..transformer_utils import VirgoWinsorizerFeature, InverseHyperbolicSine, FeaturesEntropy, FeatureSelector, InteractionFeatures
|
|
13
13
|
|
|
14
14
|
from plotly.subplots import make_subplots
|
|
15
15
|
import plotly.graph_objects as go
|
|
@@ -220,6 +220,7 @@ def data_processing_pipeline_classifier(
|
|
|
220
220
|
invhypervolsin_features = False,
|
|
221
221
|
date_features_list = False,
|
|
222
222
|
entropy_set_list = False,
|
|
223
|
+
interaction_features_cont = False,
|
|
223
224
|
pipeline_order = 'selector//winzorizer//discretizer//median_inputer//drop//correlation'
|
|
224
225
|
):
|
|
225
226
|
|
|
@@ -237,6 +238,7 @@ def data_processing_pipeline_classifier(
|
|
|
237
238
|
invhypervolsin_features (list): list of features to apply inverse hyperbolic sine
|
|
238
239
|
date_features_list (list): list of features to compute from Date field. (list of features from feature_engine)
|
|
239
240
|
entropy_set_list (list): list of dictionaries that contains features and targets to compute entropy
|
|
241
|
+
interaction_features_cont (tuple): tuple of lists of interaction features
|
|
240
242
|
pipeline_order (str): custom pipeline order eg. selector//winzorizer//discretizer//median_inputer//drop//correlation
|
|
241
243
|
Returns:
|
|
242
244
|
pipe (obj): pipeline object
|
|
@@ -249,6 +251,7 @@ def data_processing_pipeline_classifier(
|
|
|
249
251
|
median_imputer_pipe = [('median_imputer', MeanMedianImputer())] if fillna else []
|
|
250
252
|
invhypersin_pipe = [('invhypervolsin scaler', InverseHyperbolicSine(features = invhypervolsin_features))] if invhypervolsin_features else []
|
|
251
253
|
datetimeFeatures_pipe = [('date features', DatetimeFeatures(features_to_extract = date_features_list, variables = 'Date', drop_original = False))] if date_features_list else []
|
|
254
|
+
interaction_features = [("interaction features", InteractionFeatures(interaction_features_cont[0], interaction_features_cont[1]))] if interaction_features_cont else []
|
|
252
255
|
|
|
253
256
|
entropy_pipe = list()
|
|
254
257
|
if entropy_set_list:
|
|
@@ -267,6 +270,7 @@ def data_processing_pipeline_classifier(
|
|
|
267
270
|
'median_inputer':median_imputer_pipe,
|
|
268
271
|
'arcsinh_scaler': invhypersin_pipe,
|
|
269
272
|
'date_features': datetimeFeatures_pipe,
|
|
273
|
+
'interaction_features': interaction_features,
|
|
270
274
|
'entropy_features' : entropy_pipe,
|
|
271
275
|
}
|
|
272
276
|
|
|
@@ -792,7 +792,7 @@ def apply_KF(self, trends):
|
|
|
792
792
|
|
|
793
793
|
stock_eda_panel.apply_KF = apply_KF
|
|
794
794
|
|
|
795
|
-
def call_ml_objects(stock_code, client, call_models = False):
|
|
795
|
+
def call_ml_objects(stock_code, client, call_models = False, clean_name=False):
|
|
796
796
|
'''
|
|
797
797
|
call artifcats from mlflow
|
|
798
798
|
|
|
@@ -805,7 +805,11 @@ def call_ml_objects(stock_code, client, call_models = False):
|
|
|
805
805
|
'''
|
|
806
806
|
objects = dict()
|
|
807
807
|
|
|
808
|
-
|
|
808
|
+
if clean_name:
|
|
809
|
+
renamed_stock_code = stock_code.replace("^","__",).replace(".","__").replace("=","__").replace("-","__")
|
|
810
|
+
registered_model_name = f'{renamed_stock_code}_models'
|
|
811
|
+
else:
|
|
812
|
+
registered_model_name = f'{stock_code}_models'
|
|
809
813
|
latest_version_info = client.get_latest_versions(registered_model_name, stages=["Production"])
|
|
810
814
|
latest_production_version = latest_version_info[0].version
|
|
811
815
|
run_id_prod_model = latest_version_info[0].run_id
|
|
@@ -816,18 +820,27 @@ def call_ml_objects(stock_code, client, call_models = False):
|
|
|
816
820
|
)
|
|
817
821
|
|
|
818
822
|
## calling models
|
|
819
|
-
|
|
823
|
+
if clean_name:
|
|
824
|
+
path_hmm = f"runs:/{run_id_prod_model}/{renamed_stock_code}-hmm-model"
|
|
825
|
+
else:
|
|
826
|
+
path_hmm = f"runs:/{run_id_prod_model}/{stock_code}-hmm-model"
|
|
827
|
+
|
|
820
828
|
hmm_model = mlflow.pyfunc.load_model(
|
|
821
|
-
|
|
822
|
-
|
|
829
|
+
path_hmm,
|
|
830
|
+
suppress_warnings = True
|
|
823
831
|
)
|
|
824
832
|
objects['called_hmm_models'] = hmm_model
|
|
825
833
|
|
|
826
834
|
if call_models:
|
|
827
835
|
|
|
836
|
+
if clean_name:
|
|
837
|
+
path_model = f"runs:/{run_id_prod_model}/{renamed_stock_code}-forecasting-model"
|
|
838
|
+
else:
|
|
839
|
+
path_model = f"runs:/{run_id_prod_model}/{stock_code}-forecasting-model"
|
|
840
|
+
|
|
828
841
|
forecasting_model = mlflow.pyfunc.load_model(
|
|
829
|
-
|
|
830
|
-
|
|
842
|
+
path_model,
|
|
843
|
+
suppress_warnings = True
|
|
831
844
|
)
|
|
832
845
|
objects['called_forecasting_model'] = forecasting_model
|
|
833
846
|
|
{virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/transformer_utils.py
RENAMED
|
@@ -248,3 +248,44 @@ class signal_combiner(BaseEstimator, TransformerMixin):
|
|
|
248
248
|
if self.drop:
|
|
249
249
|
X = X.drop(columns = [self.prefix_up + column, self.prefix_low + column])
|
|
250
250
|
return X
|
|
251
|
+
|
|
252
|
+
class InteractionFeatures(BaseEstimator, TransformerMixin):
|
|
253
|
+
|
|
254
|
+
"""
|
|
255
|
+
Class that applies feature interaction.
|
|
256
|
+
this class is compatible with scikitlearn pipeline
|
|
257
|
+
|
|
258
|
+
Attributes
|
|
259
|
+
----------
|
|
260
|
+
feature_list1 : list
|
|
261
|
+
list of features to combine
|
|
262
|
+
feature_list2 : list
|
|
263
|
+
list of features to combine
|
|
264
|
+
|
|
265
|
+
Methods
|
|
266
|
+
-------
|
|
267
|
+
fit(additional="", X=DataFrame, y=None):
|
|
268
|
+
fit transformation.
|
|
269
|
+
transform(X=DataFrame, y=None):
|
|
270
|
+
apply feature transformation
|
|
271
|
+
"""
|
|
272
|
+
|
|
273
|
+
def __init__(self, feature_list1, feature_list2):
|
|
274
|
+
self.feature_list1 = feature_list1
|
|
275
|
+
self.feature_list2 = feature_list2
|
|
276
|
+
|
|
277
|
+
def fit(self, X, y=None):
|
|
278
|
+
return self
|
|
279
|
+
|
|
280
|
+
def simple_div_interaction(self, data, feature1, feature2, feature_name):
|
|
281
|
+
data[feature_name] = data[feature1]*data[feature2]
|
|
282
|
+
data[feature_name] = data[feature_name].replace([np.inf, -np.inf], 0)
|
|
283
|
+
data[feature_name] = data[feature_name].fillna(0)
|
|
284
|
+
return data
|
|
285
|
+
|
|
286
|
+
def transform(self, X, y=None):
|
|
287
|
+
for f1 in self.feature_list1:
|
|
288
|
+
for f2 in self.feature_list2:
|
|
289
|
+
fn = 'iterm_'+f1.replace("norm_","")+"_"+f2.replace("norm_","")
|
|
290
|
+
X = self.simple_div_interaction(X, f1, f2, fn)
|
|
291
|
+
return X
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/edge_utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules/src/edge_utils/shap_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{virgo_modules-0.4.2 → virgo_modules-0.4.4}/virgo_app/virgo_modules.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|