Skip to content

Commit

Permalink
Tutorial and Example bug fixes (#83)
Browse files Browse the repository at this point in the history
* adressing bug in tutorial

* addressing future warning

* addressing test warnings
  • Loading branch information
kbonney authored Oct 24, 2023
1 parent 28778d1 commit 86ad883
Show file tree
Hide file tree
Showing 5 changed files with 560 additions and 514 deletions.
5 changes: 2 additions & 3 deletions pvops/text/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def supervised_classifier_defs(settings_flag):
},
"RidgeClassifier": {
"clf__alpha": [0.0, 1e-3, 1.0],
"clf__normalize": [False, True],
},
"SGDClassifier": {
"clf__loss": ["squared_hinge"],
Expand Down Expand Up @@ -158,7 +157,7 @@ def supervised_classifier_defs(settings_flag):
},
"RidgeClassifier": {
"clf__alpha": [0.0, 1e-3, 1.0],
"clf__normalize": [False, True],
# "clf__normalize": [False, True],
},
"SGDClassifier": {
"clf__loss": ["squared_hinge"],
Expand Down Expand Up @@ -221,7 +220,7 @@ def supervised_classifier_defs(settings_flag):
},
"RidgeClassifier": {
"clf__alpha": [0.0, 1e-3, 1.0, 1e-4, 1e-3, 1e-2, 1e-1, 1.0],
"clf__normalize": [False, True],
# "clf__normalize": [False, True],
},
"SGDClassifier": {
"clf__loss": ["squared_hinge", "hinge", "log"],
Expand Down
2 changes: 1 addition & 1 deletion pvops/text/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def restructure(vals, inds, ind_set):
newdf[LABEL_COLUMN] = asset_sums
newdf[DATE_COLUMN] = index_sums

cmap = plt.cm.get_cmap(cmap_name, len(asset_set))
cmap = matplotlib.colormaps.get_cmap(cmap_name).resampled(len(asset_set))

graphs = []
for i, a in enumerate(asset_set):
Expand Down
4 changes: 3 additions & 1 deletion pvops/text2time/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ def om_summary_stats(om_df, meta_df, om_col_dict, meta_col_dict):
# Adding age column to om_df, but first initiating a COD column in the
# OM-data (using NANs) to be able to take the difference between two columns
om_df[meta_cod] = np.nan
om_df[meta_cod] = om_df[meta_cod].astype("O")

for i in cod_dates.index:
om_df.loc[i, meta_cod] = cod_dates[i]
om_df[meta_cod] = pd.to_datetime(om_df[meta_cod])
Expand Down Expand Up @@ -485,7 +487,7 @@ def prod_anomalies(prod_df, prod_col_dict, minval=1.0, repval=np.nan, ffill=True
prod_df.loc[mask, prod_ener] = repval

if ffill:
prod_df.loc[:, prod_ener].fillna(method="ffill", inplace=True)
prod_df.loc[:, prod_ener].ffill(inplace=True)
addressed = addressedwna

return prod_df, addressed
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 @@ -50,7 +50,7 @@ def visualize_attribute_timeseries(self, DATE_COLUMN):

def visualize_cluster_entropy(self, cols):
def eval_kmeans(X, k):
km = KMeans(n_clusters=k)
km = KMeans(n_clusters=k, n_init=10)
km.fit(X)
return km

Expand Down
1,061 changes: 553 additions & 508 deletions tutorials/tutorial_textmodule.ipynb

Large diffs are not rendered by default.

0 comments on commit 86ad883

Please sign in to comment.