Skip to content

Commit

Permalink
Funções de sensibilidade
Browse files Browse the repository at this point in the history
  • Loading branch information
soloalex1 committed Nov 24, 2019
1 parent c698b7e commit 967f492
Showing 1 changed file with 71 additions and 26 deletions.
97 changes: 71 additions & 26 deletions dp_exponential/dp_exponential.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"from itertools import combinations\n",
"from scipy.stats import expon\n",
"\n",
"data = pd.read_csv(r'dados/movie_metadata.csv')\n",
"budgets = [0.1, 1, 10]\n",
Expand Down Expand Up @@ -316,15 +318,16 @@
"\n",
"def score3(data, out):\n",
" data_countries = data.country.dropna().array\n",
" countries, values = []\n",
" countries = np.zeros(len(data_countries))\n",
" values = []\n",
" for i in range(0, len(data_countries)):\n",
" if(data_countries[i] not in countries):\n",
" countries[data_countries[i]] = 0\n",
" for i in data:\n",
" if(i.country != 'None'):\n",
" countries[i.country] += 1\n",
" if(i.country in saida):\n",
" values.append(i.country)\n",
" countries[i] = 0\n",
" for i in range(0, len(data_countries)):\n",
" if(data.iloc[i].country != 'None'):\n",
" countries[i] += 1\n",
" if(data.iloc[i].country in out):\n",
" values.append(data.iloc[i].country)\n",
" else:\n",
" values.append(0)\n",
" return values"
Expand All @@ -339,18 +342,15 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\users\\alexandre\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\ipykernel_launcher.py:29: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\n"
]
}
],
"source": [
Expand All @@ -365,7 +365,7 @@
" for j in range(0, len(mat) - 1):\n",
" for k in range(j + 1, len(mat)):\n",
" psens = abs(mat[i][j] - mat[i][k])\n",
" if(sense <= psens):\n",
" if(sense < psens):\n",
" sense = psens\n",
" return sense\n",
"\n",
Expand All @@ -379,36 +379,81 @@
" for j in range(0, len(mat) - 1):\n",
" for k in range(j + 1, len(mat)):\n",
" psens = abs(mat[i][j] - mat[i][k])\n",
" if(sense <= psens):\n",
" if(sense < psens):\n",
" sense = psens\n",
" return sense\n",
"\n",
"def sense_q3(data):\n",
" mat = []\n",
" sense = 0\n",
" country_list = []\n",
" for i in data:\n",
" if(i.country not in country_list and i.country != 'None'):\n",
" country.list.append(i.country)\n",
" return sense\n",
" mat = []\n",
" for i in range(0, len(data)):\n",
" if(data.iloc[i].country not in country_list and data.iloc[i].country != 'None'):\n",
" country_list.append(data.iloc[i].country)\n",
" results = combinations(country_list, 3)\n",
" \n",
" for r in results:\n",
" mat.append(score3(data, r))\n",
"\n",
" for i in range(0, len(mat)):\n",
" for j in range(0, len(data)):\n",
" for k in range(0, len(data)):\n",
" psens = abs(mat[i][j] - mat[i][k])\n",
" if(psens < sense):\n",
" sense = psens\n",
" return sense\n",
"\n",
"sense_q2(data)"
"sense_q3(data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Mecanismo Exponencial"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def exponencial(data, sense, res, budget):\n",
" return"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Randomização de consultas"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"# TODO"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Execução"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"# TODO"
]
}
],
"metadata": {
Expand Down

0 comments on commit 967f492

Please sign in to comment.