Skip to content

Commit

Permalink
Create financial_planning_ai.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jul 14, 2024
1 parent 5267910 commit 7bd0a06
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions features/autonomous_financial_planning/financial_planning_ai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# File name: financial_planning_ai.py
import gym
import numpy as np
from stable_baselines3 import PPO

class FinancialPlanningAI:
def __init__(self, env):
self.env = env
self.model = PPO('MlpPolicy', env, verbose=1)

def train(self):
self.model.learn(total_timesteps=10000)
self.model.save("financial_planning_ai")

def plan(self, state):
action, _ = self.model.predict(state)
return action

env = gym.make('FinancialPlanningEnv-v0')
financial_planning_ai = FinancialPlanningAI(env)
financial_planning_ai.train()

0 comments on commit 7bd0a06

Please sign in to comment.