Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Agent_class.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "e7d149b5",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "8fe2fda3",
"metadata": {},
"outputs": [],
"source": [
"class Agent():\n",
" def __init__(self, balance, performance, portfolio, stock_worth):\n",
" self.balance = balance\n",
" self.performance = performance\n",
" self.portfolio = portfolio\n",
" self.stock_worth = stock_worth\n",
" \n",
" def action(self, stock_tensor):\n",
" action_list = []\n",
" stock_array = np.array(stock_tensor)\n",
" actionMap = {0:0,1:1,2:2}\n",
" for stock in stock_array:\n",
" action_list.append(actionMap[stock.argmax()]) \n",
" return action_list"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "c14c6302",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\\nTesting\\n\\nmy_agent = Agent(1,2,3,4)\\nstock_tensor = np.array([[0.1,0.5,0.3],[0.6,0.5,0.3],[0.1,0.2,0.3],[0.1,0.5,0.9],[0.1,0.1,0.3],[0.1,0.8,0.3],[0.8,0.5,0.3]])\\n\\nprint(my_agent.action(stock_tensor))\\n\\n'"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"'''\n",
"Testing\n",
"\n",
"my_agent = Agent(1,2,3,4)\n",
"stock_tensor = np.array([[0.1,0.5,0.3],[0.6,0.5,0.3],[0.1,0.2,0.3],[0.1,0.5,0.9],[0.1,0.1,0.3],[0.1,0.8,0.3],[0.8,0.5,0.3]])\n",
"\n",
"print(my_agent.action(stock_tensor))\n",
"\n",
"'''"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d646e41e",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
441 changes: 441 additions & 0 deletions Classifier.ipynb

Large diffs are not rendered by default.