jostyposty commited on
Commit
ec9247d
1 Parent(s): 8f85198

docs: Added how to load the model

Browse files
Files changed (1) hide show
  1. README.md +19 -3
README.md CHANGED
@@ -26,10 +26,26 @@ model-index:
26
  ## Usage
27
 
28
  ```python
 
 
 
 
29
 
30
- model = load_from_hub(repo_id="jostyposty/drl-course-unit-02-taxi-v3", filename="q-learning.pkl")
31
 
32
- # Don't forget to check if you need to add additional attributes (is_slippery=False etc)
33
- env = gym.make(model["env_id"])
 
 
 
 
 
 
 
 
 
 
 
 
34
  ```
35
 
 
26
  ## Usage
27
 
28
  ```python
29
+ import gymnasium as gym
30
+ import pickle5 as pickle
31
+ from huggingface_sb3 import load_from_hub
32
+ from hf_course_code import evaluate_agent # Code from the course https://huggingface.co/learn/deep-rl-course/unit2/hands-on#the-evaluation-method-
33
 
34
+ model_pickle = load_from_hub(repo_id="jostyposty/drl-course-unit-02-taxi-v3", filename="q-learning.pkl")
35
 
36
+ with open(model_pickle, "rb") as f:
37
+ model = pickle.load(f)
38
+
39
+ env = gym.make(model["env_id"])
40
+
41
+ mean_reward, std_reward = evaluate_agent(
42
+ env,
43
+ model["max_steps"],
44
+ model["n_eval_episodes"],
45
+ model["qtable"],
46
+ model["eval_seed"],
47
+ )
48
+ result = mean_reward - std_reward
49
+ print(f"Result={result:.2f}, Mean_reward={mean_reward:.2f} +/- {std_reward:.2f}")
50
  ```
51