virgo-modules 0.4.3__py3-none-any.whl → 0.4.5__py3-none-any.whl
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/src/edge_utils/conformal_utils.py +3 -3
- virgo_modules/src/edge_utils/edge_utils.py +5 -1
- virgo_modules/src/transformer_utils.py +41 -0
- {virgo_modules-0.4.3.dist-info → virgo_modules-0.4.5.dist-info}/METADATA +1 -1
- {virgo_modules-0.4.3.dist-info → virgo_modules-0.4.5.dist-info}/RECORD +8 -8
- {virgo_modules-0.4.3.dist-info → virgo_modules-0.4.5.dist-info}/LICENSE +0 -0
- {virgo_modules-0.4.3.dist-info → virgo_modules-0.4.5.dist-info}/WHEEL +0 -0
- {virgo_modules-0.4.3.dist-info → virgo_modules-0.4.5.dist-info}/top_level.txt +0 -0
|
@@ -21,14 +21,14 @@ def get_conformal_classifiers(model, data, targets):
|
|
|
21
21
|
def log_confmodels(runid, classifiers):
|
|
22
22
|
with mlflow.start_run(run_id=runid) as run:
|
|
23
23
|
for i,classifier in enumerate(classifiers):
|
|
24
|
-
mlflow.sklearn.log_model(classifier,f"
|
|
24
|
+
mlflow.sklearn.log_model(classifier,name = f"conformal_model-{i}")
|
|
25
25
|
print('models were logged')
|
|
26
26
|
|
|
27
27
|
def load_confmodel(runid, target_variables):
|
|
28
28
|
classifiers = list()
|
|
29
29
|
for i in range(len(target_variables)):
|
|
30
|
-
folder = f"
|
|
31
|
-
model = mlflow.sklearn.load_model(f"runs:/{runid}/{folder}")
|
|
30
|
+
folder = f"conformal_model-{i}"
|
|
31
|
+
model = mlflow.sklearn.load_model(f"runs:/{runid}/{folder}",)
|
|
32
32
|
classifiers.append(model)
|
|
33
33
|
return classifiers
|
|
34
34
|
|
|
@@ -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
|
|
|
@@ -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
|
|
@@ -6,13 +6,13 @@ virgo_modules/src/hmm_utils.py,sha256=D7axAnCdSe1_1EgRyli2PAnM2f6699hTY9GcxjPXG-
|
|
|
6
6
|
virgo_modules/src/pull_artifacts.py,sha256=5OPrgR7pcMSdpbevDRhf0ebk7g7ZRjff4NpTIIWAKjE,1989
|
|
7
7
|
virgo_modules/src/re_utils.py,sha256=DBY_VBB1wKm5D7znutpF_66CTLZhJfx54h8Ws0YzdN4,74641
|
|
8
8
|
virgo_modules/src/ticketer_source.py,sha256=jxP-OOeoyN2JxRQg-mX6t6WNJXiIrhWKDywDxpYANxU,101977
|
|
9
|
-
virgo_modules/src/transformer_utils.py,sha256=
|
|
9
|
+
virgo_modules/src/transformer_utils.py,sha256=ysCUp3cB3_7Jr9OHDqhg2_6Vu0k1YVjfqbvQNbxpbhI,8990
|
|
10
10
|
virgo_modules/src/edge_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
virgo_modules/src/edge_utils/conformal_utils.py,sha256=
|
|
12
|
-
virgo_modules/src/edge_utils/edge_utils.py,sha256=
|
|
11
|
+
virgo_modules/src/edge_utils/conformal_utils.py,sha256=WK54ctvdnFrCAv3_slFBC71Ojy9xgC1wODR7xmvXGgg,3743
|
|
12
|
+
virgo_modules/src/edge_utils/edge_utils.py,sha256=unCrkimwzlJx-osUWz6f6Vfiuv-unIATYva5UkK-Xik,18661
|
|
13
13
|
virgo_modules/src/edge_utils/shap_utils.py,sha256=OMKVO-4gtOng9GeSuhEgAEQe4FF3AtqXjm-GUBLqYFc,3349
|
|
14
|
-
virgo_modules-0.4.
|
|
15
|
-
virgo_modules-0.4.
|
|
16
|
-
virgo_modules-0.4.
|
|
17
|
-
virgo_modules-0.4.
|
|
18
|
-
virgo_modules-0.4.
|
|
14
|
+
virgo_modules-0.4.5.dist-info/LICENSE,sha256=pNgFyCYgmimaw0o6V20JupZLROycAnOA_HDDh1tX2V4,1097
|
|
15
|
+
virgo_modules-0.4.5.dist-info/METADATA,sha256=GR7pTBoguHajgjq17Z6gXRSdjRz-3w4X5QD3-0N7Ge4,876
|
|
16
|
+
virgo_modules-0.4.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
17
|
+
virgo_modules-0.4.5.dist-info/top_level.txt,sha256=ZjI-qEkDtT-8mFwGAWnXfqPOKEGlIhWRW1es1VyXc60,14
|
|
18
|
+
virgo_modules-0.4.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|