File size: 666 Bytes
0443094
899f835
dea534d
0443094
9df705a
 
 
 
875d114
 
eb3ed5c
875d114
 
 
9df705a
899f835
0443094
ab9ccf0
608b829
ab9ccf0
0443094
9de19f3
c04575a
f82d2e5
d134813
0443094
 
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
import gradio as gr
import pickle
import numpy as np

class QModel():
    def __init__(self):
        self.qtable = qtab
        
    def predict(self,state_n, n_questions=1):
        n_questions = int(n_questions)
        state_n = int(state_n)
        if (n_questions==1):
            return np.argmax(self.qtable[state_n][:])
        return np.argsort(self.qtable[state_n][:])[-n_questions:]

learner = pickle.load(open("q-learn-multiply-game.pkl", "rb"))

def predict_next_questions(state, n_questions):
    
    return learner.predict(state, n_questions)


intf = gr.Interface(fn=predict_next_questions, inputs="number", outputs="json")

intf.launch()