virgo-modules 0.0.88__tar.gz → 0.0.89__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.0.88 → virgo_modules-0.0.89}/PKG-INFO +1 -1
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/setup.py +1 -1
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules/src/ticketer_source.py +103 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules.egg-info/PKG-INFO +1 -1
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/LICENSE +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/README.md +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/setup.cfg +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules/__init__.py +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules/src/__init__.py +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules/src/aws_utils.py +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules/src/edge_utils.py +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules/src/pull_artifacts.py +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules/src/re_utils.py +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules.egg-info/SOURCES.txt +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules.egg-info/dependency_links.txt +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules.egg-info/requires.txt +0 -0
- {virgo_modules-0.0.88 → virgo_modules-0.0.89}/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.0.
|
|
8
|
+
version="0.0.89",
|
|
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.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules/src/ticketer_source.py
RENAMED
|
@@ -147,6 +147,109 @@ class FeatureSelector(BaseEstimator, TransformerMixin):
|
|
|
147
147
|
def transform(self, X, y=None):
|
|
148
148
|
return X[self.columns]
|
|
149
149
|
|
|
150
|
+
class features_entropy(BaseEstimator, TransformerMixin):
|
|
151
|
+
"""
|
|
152
|
+
Class that creates a feature that calculate entropy for a given feature classes, but it might get some leackeage in the training set.
|
|
153
|
+
this class is compatible with scikitlearn pipeline
|
|
154
|
+
|
|
155
|
+
Attributes
|
|
156
|
+
----------
|
|
157
|
+
columns : list
|
|
158
|
+
list of features to select
|
|
159
|
+
entropy_map: pd.DataFrame
|
|
160
|
+
dataframe of the map with the entropies per class
|
|
161
|
+
perc: float
|
|
162
|
+
percentage of the dates using for calculate the entropy map
|
|
163
|
+
|
|
164
|
+
Methods
|
|
165
|
+
-------
|
|
166
|
+
fit(additional="", X=DataFrame, y=None):
|
|
167
|
+
fit transformation.
|
|
168
|
+
transform(X=DataFrame, y=None):
|
|
169
|
+
apply feature transformation
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
def __init__(self, features, target, feature_name = None, feature_type = 'discrete', perc = 0.5, default_null = 0.99):
|
|
173
|
+
|
|
174
|
+
self.features = features
|
|
175
|
+
self.feature_type = feature_type
|
|
176
|
+
self.target = target
|
|
177
|
+
self.perc = perc
|
|
178
|
+
self.default_null = default_null
|
|
179
|
+
|
|
180
|
+
if not feature_name:
|
|
181
|
+
self.feature_name = '_'.join(features)
|
|
182
|
+
self.feature_name = self.feature_name + '_' + target + '_' + feature_type
|
|
183
|
+
else:
|
|
184
|
+
self.feature_name = feature_name
|
|
185
|
+
|
|
186
|
+
def fit(self, X, y=None):
|
|
187
|
+
|
|
188
|
+
unique_dates = list(X['Date'].unique())
|
|
189
|
+
unique_dates.sort()
|
|
190
|
+
|
|
191
|
+
total_length = len(unique_dates)
|
|
192
|
+
cut = int(round(total_length*self.perc,0))
|
|
193
|
+
train_dates = unique_dates[:cut]
|
|
194
|
+
max_train_date = max(train_dates)
|
|
195
|
+
|
|
196
|
+
X_ = X[X['Date'] <= max_train_date]
|
|
197
|
+
df = pd.merge(X_, y, left_index=True, right_index=True, how = 'left').copy()
|
|
198
|
+
|
|
199
|
+
column_list = [f'{self.feature_type}_signal_{colx}' for colx in self.features]
|
|
200
|
+
|
|
201
|
+
df_aggr = (
|
|
202
|
+
df
|
|
203
|
+
.groupby(column_list, as_index = False)
|
|
204
|
+
.apply(
|
|
205
|
+
lambda x: pd.Series(
|
|
206
|
+
dict(
|
|
207
|
+
counts = x[self.target].count(),
|
|
208
|
+
trues=(x[self.target] == 1).sum(),
|
|
209
|
+
falses=(x[self.target] == 0).sum(),
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
.assign(
|
|
214
|
+
trues_rate=lambda x: x['trues'] / x['counts']
|
|
215
|
+
)
|
|
216
|
+
.assign(
|
|
217
|
+
falses_rate=lambda x: x['falses'] / x['counts']
|
|
218
|
+
)
|
|
219
|
+
.assign(
|
|
220
|
+
log2_trues = lambda x: np.log2(1/x['trues_rate'])
|
|
221
|
+
)
|
|
222
|
+
.assign(
|
|
223
|
+
log2_falses = lambda x: np.log2(1/x['falses_rate'])
|
|
224
|
+
)
|
|
225
|
+
.assign(
|
|
226
|
+
comp1 = lambda x: x['trues_rate']*x['log2_trues']
|
|
227
|
+
)
|
|
228
|
+
.assign(
|
|
229
|
+
comp2 = lambda x: x['falses_rate']*x['log2_falses']
|
|
230
|
+
)
|
|
231
|
+
.assign(
|
|
232
|
+
class_entropy = lambda x: np.round(x['comp1']+x['comp2'],3)
|
|
233
|
+
)
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
self.column_list = column_list
|
|
237
|
+
self.entropy_map = (
|
|
238
|
+
df_aggr
|
|
239
|
+
[column_list+['class_entropy']]
|
|
240
|
+
.rename(columns = {'class_entropy': self.feature_name})
|
|
241
|
+
.copy()
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
del df, df_aggr
|
|
245
|
+
return self
|
|
246
|
+
|
|
247
|
+
def transform(self, X, y=None):
|
|
248
|
+
|
|
249
|
+
X = X.merge(self.entropy_map, on=self.column_list, how = 'left')
|
|
250
|
+
X[self.feature_name] = X[self.feature_name].fillna(self.default_null)
|
|
251
|
+
return X
|
|
252
|
+
|
|
150
253
|
def sharpe_ratio(return_series):
|
|
151
254
|
|
|
152
255
|
'''
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{virgo_modules-0.0.88 → virgo_modules-0.0.89}/virgo_app/virgo_modules.egg-info/top_level.txt
RENAMED
|
File without changes
|