Skip to content

Commit

Permalink
moa data classfication
Browse files Browse the repository at this point in the history
  • Loading branch information
JKomorniczak committed Nov 6, 2023
1 parent 8a24381 commit 4e53877
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions MOA_Data.py
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')
Binary file modified foo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4e53877

Please sign in to comment.