Skip to content

Commit

Permalink
Miscellaneous fixes relevant to text2time, time, timeseries AIT modul…
Browse files Browse the repository at this point in the history
…e tutorials (#100)

* fixes associated with text module

* fixes associated with AIT tutorial

---------

Co-authored-by: kbonney <[email protected]>
  • Loading branch information
agmoore4 and kbonney authored Oct 25, 2024
1 parent be87631 commit bc345b5
Show file tree
Hide file tree
Showing 6 changed files with 571 additions and 646 deletions.
2 changes: 1 addition & 1 deletion pvops/text/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def classification_deployer(
.. code-block:: python
scoring = make_scorer(f1_score, average = 'weighted')
scoring = make_scorer(f1_score, average = 'weighted', pos_label = None)
For unsupervised classifiers, one could specify
Expand Down
12 changes: 6 additions & 6 deletions pvops/text/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def supervised_classifier_defs(settings_flag):
"clf__C": np.logspace(0, 4, 10),
},
"PassiveAggressiveClassifier": {
"clf__C": [0.0, 0.01, 0.1, 1.0],
"clf__C": [0.001, 0.01, 0.1, 1.0],
"clf__loss": ["hinge", "squared_hinge"],
},
"RidgeClassifier": {
Expand Down Expand Up @@ -119,7 +119,7 @@ def supervised_classifier_defs(settings_flag):
"AdaBoostClassifier": {
"clf__n_estimators": [50, 100],
"clf__learning_rate": [1.0, 0.9, 0.8],
"clf__algorithm": ["SAMME.R"],
"clf__algorithm": ["SAMME"],
},
}
elif settings_flag == "normal":
Expand Down Expand Up @@ -152,7 +152,7 @@ def supervised_classifier_defs(settings_flag):
"clf__C": np.logspace(0, 4, 10),
},
"PassiveAggressiveClassifier": {
"clf__C": [0.0, 0.01, 0.1, 1.0],
"clf__C": [0.001, 0.01, 0.1, 1.0],
"clf__loss": ["hinge", "squared_hinge"],
},
"RidgeClassifier": {
Expand Down Expand Up @@ -182,7 +182,7 @@ def supervised_classifier_defs(settings_flag):
"AdaBoostClassifier": {
"clf__n_estimators": [50, 100],
"clf__learning_rate": [1.0, 0.9, 0.8],
"clf__algorithm": ["SAMME.R"],
"clf__algorithm": ["SAMME"],
},
}
elif settings_flag == "detailed":
Expand Down Expand Up @@ -215,7 +215,7 @@ def supervised_classifier_defs(settings_flag):
"clf__C": np.logspace(0, 4, 10),
},
"PassiveAggressiveClassifier": {
"clf__C": [0.0, 0.01, 0.1, 1.0],
"clf__C": [0.001, 0.01, 0.1, 1.0],
"clf__loss": ["hinge", "squared_hinge"],
},
"RidgeClassifier": {
Expand Down Expand Up @@ -245,7 +245,7 @@ def supervised_classifier_defs(settings_flag):
"AdaBoostClassifier": {
"clf__n_estimators": [30, 50, 100, 150, 300],
"clf__learning_rate": [1.0, 0.9, 0.8, 0.4],
"clf__algorithm": ["SAMME.R", "SAMME"],
"clf__algorithm": ["SAMME"],
},
}

Expand Down
3 changes: 1 addition & 2 deletions pvops/timeseries/models/AIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,11 @@ def _load_params(self):
(0.06624491753542901, [0, 0])]

def predict_subset(self, prod_df, scaler, model_terms, prod_col_dict):
prod_df = prod_df.copy()
self.check_data(prod_df, prod_col_dict)

"""1. Standardize the data using same scales"""
for k, d in scaler.items():
data = prod_df[prod_col_dict[k]]
data = prod_df[prod_col_dict[k]].copy()
scaled_data = self._apply_transform(data, d)
prod_df[self._col_scaled_prefix + prod_col_dict[k]] = scaled_data

Expand Down
2 changes: 1 addition & 1 deletion tutorials/text_class_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def classify_supervised(
pipeline_steps = [
("doc2vec", nlp_utils.Doc2VecModel()), ("clf", None)]

scoring = make_scorer(f1_score, average="weighted")
scoring = make_scorer(f1_score, average="weighted", pos_label=None)
self.greater_is_better = True

if user_defined_classes is None or user_defined_search_space is None:
Expand Down
89 changes: 36 additions & 53 deletions tutorials/tutorial_AIT_timeseries.ipynb

Large diffs are not rendered by default.

1,109 changes: 526 additions & 583 deletions tutorials/tutorial_textmodule.ipynb

Large diffs are not rendered by default.

0 comments on commit bc345b5

Please sign in to comment.