-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplot_knowledge_bar.py
More file actions
36 lines (27 loc) · 1.04 KB
/
plot_knowledge_bar.py
File metadata and controls
36 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# noqa
"""
BarPlotter Example
==================
This example shows how to use the ``BarPlotter`` class
to generate a bar chart to study the estimated mean of
the learner's knowledge and our confidence level (via error bars).
In this example, we use the ``NoveltyClassifier`` to build
a representation of the learner's knowledge. You could also use
other classifiers like ``KnowledgeClassifier`` (for building
knowledge representation) or ``InterestClassifier`` (for building
interest representation).
"""
from truelearn import learning, datasets
from truelearn.utils import visualisations
import plotly.io as pio
data, _, _ = datasets.load_peek_dataset(test_limit=0, verbose=False)
# select a learner from data
_, learning_events = data[12]
classifier = learning.NoveltyClassifier()
for event, label in learning_events:
classifier.fit(event, label)
plotter = visualisations.BarPlotter()
plotter.plot(classifier.get_learner_model().knowledge, top_n=10)
# you can also use plotter.show()
# which is a shorthand for calling pio
pio.show(plotter.figure)