This repository has been archived on 2023-06-18. You can view files and clone it, but cannot push or open issues or pull requests.
va-project/presentation_notebook.ipynb

278 lines
7.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import ipywidgets as widgets\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import math\n",
"import pandas as pd \n",
"from IPython.display import Image, display\n",
"\n",
"#Newest_York = r'Newest_York.png'\n",
"\n",
"#display(Image(filename=Newest_York, width=700, height=500))"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>I + II) Function for getting <b style=\"color:DodgerBlue;\">Estimated Growth & Past Performance </b> Scores --> <b>Sigmoid fucntion</b></h2>"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6694062359364cc2ab6544bc4c5c8130",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=5.746777777777778, description='x', max=200.0, min=-200.0, step=1.0), …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function __main__.plot_function(x)>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"not_normalized = pd.read_csv('Elaborated_Data/Not_Normalized.csv')\n",
"\n",
"\n",
"average_score = not_normalized['Estimated Growth'].str.rstrip('%').astype(float).mean() #STARTING POINT (Analyt's yearly estimated growth (%) for next 5 years)\n",
"\n",
"slope = 0.1\n",
"\n",
"def plot_function(x):\n",
" y = (200 / (1 + math.e**(-slope * (-average_score + x))))\n",
" plt.plot(x_values, y_values)\n",
" plt.scatter(x, y, color='red', label=f'x={x}')\n",
" plt.xlabel('Estimated Growth (yearly in %)')\n",
" plt.ylabel('Stockingly Score')\n",
" plt.title('Estimated growth Score = sigmoid(Estimated growth %)')\n",
" plt.legend()\n",
" plt.grid(False) \n",
" plt.axhline(0, color='black') \n",
" plt.axvline(0, color='black') \n",
"\n",
" plt.axhline(y, color='green') \n",
"\n",
" plt.xlim(-200, 200) \n",
" plt.ylim(-10, 250) \n",
"\n",
" plt.show()\n",
"\n",
"# Generate x values from -100 to 100\n",
"x_values = np.linspace(-200, 200, 200)\n",
"y_values = (200 / (1 + np.exp(-slope * (-average_score + x_values))))\n",
"\n",
"widgets.interact(plot_function, x=widgets.FloatSlider(min=-200, max=200, step=1, value=average_score))\n",
"\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>III) Function for getting <b style=\"color:DodgerBlue;\">Financial health --> </b> score: <b>reverse exponential</b></h2>"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5306c1272eb748aeb69bdd401c9262ed",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=4.78006822089688, description='x', max=50.0, step=0.5), Output()), _do…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function __main__.plot_function(x)>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sys\n",
"sys.path.append('../group-1')\n",
"import math\n",
"import pandas as pd\n",
"import numpy as np \n",
"\n",
"not_normalized = pd.read_csv('Elaborated_Data/Not_Normalized.csv')\n",
"\n",
"\n",
"average_score = not_normalized['Financial Health'].mean() #STARTING POINT (Mean Assets/debts)\n",
"\n",
"\n",
"slope = 0.1\n",
"\n",
"def plot_function(x):\n",
" y = 200 - 200*math.e**(-0.138 * (x))\n",
" plt.plot(x_values, y_values)\n",
" plt.scatter(x, y, color='red', label=f'x={x}')\n",
" plt.xlabel('Total Assets/Total Debt')\n",
" plt.ylabel('Stockingly Score')\n",
" plt.title('Financial Health Score = ReverseExp(TOT Assets/TOT Debts)')\n",
" plt.legend()\n",
" plt.grid(False) \n",
" plt.axhline(0, color='black') \n",
" plt.axvline(0, color='black') \n",
" plt.axhline(y, color='blue') \n",
" plt.xlim(0, 100) \n",
" plt.ylim(-10, 250) \n",
" plt.show()\n",
"\n",
"x_values = np.linspace(-200, 200, 200)\n",
"y_values = 200 - 200*math.e**(-0.138 * (x_values))\n",
"\n",
"\n",
"widgets.interact(plot_function, x=widgets.FloatSlider(min=0, max=50, step=0.5, value=average_score))\n",
"\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2> IV) Function for getting <b style=\"color:DodgerBlue;\">valuation$ score</b> from PEG: --><b>Custom Fractal</b></h2>"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5e249d428e5a4413969ea198ea92763e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(FloatSlider(value=2.8344899999999997, description='x', max=30.0), Output()), _dom_classe…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<function __main__.plot_function(x)>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sys\n",
"sys.path.append('../group-1')\n",
"import math\n",
"import pandas as pd\n",
"import numpy as np \n",
"\n",
"not_normalized = pd.read_csv('Elaborated_Data/Not_Normalized.csv')\n",
"\n",
"average_score = not_normalized['Valuation'].mean() #STARTING POINT (MEAN PEG RATIO)\n",
"\n",
"\n",
"\n",
"\n",
"def plot_function(x):\n",
" y = (200/(1+(1/9*x**2)))\n",
" plt.plot(x_values, y_values)\n",
" plt.scatter(x, y, color='red', label=f'x={x}')\n",
" plt.xlabel('PEG value')\n",
" plt.ylabel('Stockingly Score Valuation')\n",
" plt.title('Valuation Score = FractalPolynomial(PEG)')\n",
" plt.legend()\n",
" plt.grid(False) \n",
" plt.axhline(0, color='black') \n",
" plt.axvline(0, color='black') \n",
" plt.axhline(y, color='blue') \n",
" plt.xlim(0, 100) \n",
" plt.ylim(-10, 250) \n",
" plt.show()\n",
"\n",
"x_values = np.linspace(0, 200, 2000)\n",
"\n",
"y_values = (200/(1+(1/9*x_values**2)))\n",
"\n",
"widgets.interact(plot_function, x=widgets.FloatSlider(min=0, max=30, step=0.1, value=average_score))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "analyticvisual",
"language": "python",
"name": "visualanalytics"
},
"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.11.0"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}