Skip to content

Commit

Permalink
tweaks to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tms-bananaquit committed Jul 22, 2022
1 parent bcbce7d commit c74c2a7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 36 deletions.

Large diffs are not rendered by default.

21 changes: 6 additions & 15 deletions docs/source/examples/concept_drift/concept_drift_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,8 @@
" clf = GaussianNB()\n",
" clf.fit(X_train, y_train)\n",
"\n",
" n += 1"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [],
"source": [
" n += 1\n",
"\n",
"status['original_accuracy'] = acc_orig"
]
},
Expand Down Expand Up @@ -428,12 +421,10 @@
"source": [
"\n",
"After drift is induced, the accuracy decreases enough for ADWIN to shrink its\n",
"window and alarm; subsequent windows also include data from the old regime,\n",
"so drift continues to be detected until the window shrinks enough to be\n",
"comprised mostly by the new regime.\n",
"\n",
"We can see that, by retraining on the new window of data reported by ADWIN, \n",
"the accuracy of the classifier is improved over time."
"window and alarm; subsequent windows also include data from the old regime, so\n",
"drift continues to be detected until the window shrinks enough to be comprised\n",
"mostly by the new regime. We can see that, by retraining on the new window of\n",
"data reported by ADWIN, the accuracy of the classifier is improved over time."
]
},
{
Expand Down
11 changes: 6 additions & 5 deletions examples/change_detection_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# corrected, so change does occur.
#
# These change detectors can be applied to any given single variable; below,
# they are applied to var2.
# they are applied to `var2` and the `max_sustained_wind_speed` columns in the
# respective datasets.

# In[1]:

Expand Down Expand Up @@ -183,11 +184,11 @@
# be unreasonable.
#

# # ADaptive WINdowing (ADWIN)
# ## ADaptive WINdowing (ADWIN)
#
# ADWIN is a change detection algorithm that can be used to monitor a real-valued number. ADWIN maintains a window of the data stream, which grows to the right as new elements are received. When the mean of the feature in one of the subwindows is different enough, ADWIN drops older elements in its window until this ceases to be the case.

# In[58]:
# In[3]:


## Setup ##
Expand All @@ -212,15 +213,15 @@
rec_list.append([retrain_start, retrain_end])


# In[66]:
# In[4]:


## Plotting ##

# plot the monitored variable and the status of the detector
plt.figure(figsize=(20, 6))
plt.scatter("index", "actual value", data=status, label="max_sustained_wind_speed", alpha=.5)
plt.plot("index", "ADWIN mean", data=status, color='red', linewidth=2)
plt.plot("index", "ADWIN mean", data=status, color='blue', linewidth=3)
plt.grid(False, axis="x")
plt.xticks(fontsize=16)
plt.yticks(fontsize=16)
Expand Down
14 changes: 4 additions & 10 deletions examples/concept_drift_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@

n += 1


# In[41]:


status['original_accuracy'] = acc_orig


Expand Down Expand Up @@ -348,12 +344,10 @@

#
# After drift is induced, the accuracy decreases enough for ADWIN to shrink its
# window and alarm; subsequent windows also include data from the old regime,
# so drift continues to be detected until the window shrinks enough to be
# comprised mostly by the new regime.
#
# We can see that, by retraining on the new window of data reported by ADWIN,
# the accuracy of the classifier is improved over time.
# window and alarm; subsequent windows also include data from the old regime, so
# drift continues to be detected until the window shrinks enough to be comprised
# mostly by the new regime. We can see that, by retraining on the new window of
# data reported by ADWIN, the accuracy of the classifier is improved over time.

# ## Drift Detection Method (DDM)

Expand Down

0 comments on commit c74c2a7

Please sign in to comment.