-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a24381
commit 4e53877
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
from sklearn.naive_bayes import GaussianNB | ||
from strlearn.streams import ARFFParser | ||
from sklearn.metrics import accuracy_score | ||
import matplotlib.pyplot as plt | ||
from scipy.signal import medfilt | ||
|
||
streams = os.listdir('data/moa') | ||
streams.remove('.DS_Store') | ||
print(streams) | ||
|
||
chunks = 500 | ||
|
||
fig, ax = plt.subplots(4,3,figsize=(12,7), sharex=True, sharey=True) | ||
ax = ax.ravel() | ||
|
||
for s_id, s in enumerate(streams): | ||
data = ARFFParser('data/moa/%s' % s) | ||
clf = GaussianNB() | ||
scores = [] | ||
|
||
for c in range(chunks): | ||
X, y = data.get_chunk() | ||
if c==0: | ||
clf.fit(X, y) | ||
else: | ||
scores.append(accuracy_score(y, clf.predict(X))) | ||
|
||
ax[s_id].plot(medfilt(scores,11)) | ||
ax[s_id].grid(ls=':') | ||
ax[s_id].set_title(s.split('.')[0]) | ||
if s_id in [0,3,6,9]: | ||
ax[s_id].set_ylabel('accuracy') | ||
|
||
plt.tight_layout() | ||
plt.savefig('foo.png') |