Skip to content

Commit

Permalink
feat: add amount of file calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Lena Ebner committed Jan 1, 2024
1 parent 60df831 commit 58d11ff
Showing 1 changed file with 42 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2023-12-27T14:38:07.208570100Z",
Expand All @@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 11,
"metadata": {
"ExecuteTime": {
"end_time": "2023-12-27T14:48:33.003116200Z",
Expand All @@ -43,23 +43,40 @@
"id": "fbykrjkOjZWq",
"outputId": "8c8bd4c8-16e8-41fe-a87b-e9e0d797beac"
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Amount of files: 32\n"
]
}
],
"source": [
"\n",
"base_path = \"D:\\\\Documents\\\\GitHub\\\\CIR\\\\experiments\\\\UserData\"\n",
"base_path = \"./UserData/\"\n",
"# base_path = \"D:\\\\Documents\\\\GitHub\\\\CIR\\\\experiments\\\\UserData\"\n",
"\n",
"results = {}\n",
"amount_of_files = 0\n",
"\n",
"# Loop over all the files\n",
"for dir in os.listdir(base_path):\n",
" dir_path = base_path + \"\\\\\" + dir\n",
" dir_path = base_path + dir\n",
" # dir_path = base_path + \"\\\\\" + dir\n",
"\n",
" # Only check the directories\n",
" if os.path.isdir(dir_path):\n",
" for file in os.listdir(dir_path):\n",
" file_path = dir_path + \"\\\\\" + file\n",
" file_path = dir_path + \"/\" + file\n",
" # file_path = dir_path + \"\\\\\" + file\n",
"\n",
" # Only check the files\n",
" if not os.path.isdir(file_path):\n",
" log_path = dir_path + \"\\\\logs\"\n",
" amount_of_files += 1\n",
" log_path = dir_path + \"/logs\"\n",
" # log_path = dir_path + \"\\\\logs\"\n",
" \n",
" # Get the excel file and convert to an array with 0, 0.5 and 1\n",
" # representing neutral, slight smile and smile\n",
" df = pd.read_excel(file_path)\n",
Expand All @@ -71,7 +88,9 @@
" with open(log_path + \"/\" + log, \"r\") as log_file:\n",
" json_log = json.load(log_file)\n",
" smile_degree_array = [entry['smileDegree'] for entry in json_log]\n",
" results[file[:-5]] = [result_array, smile_degree_array]"
" results[file[:-5]] = [result_array, smile_degree_array]\n",
" \n",
"print(f\"Amount of files: {amount_of_files}\")"
]
},
{
Expand All @@ -83,16 +102,16 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Total MSE \t = -0.13205479156940012\n",
"MSE A \t\t = -0.13099312341198133\n",
"MSE B \t\t = -0.133265373577282\n"
"Total MSE \t = -0.1195553075097073\n",
"MSE A \t\t = -0.11021458716866875\n",
"MSE B \t\t = -0.12993050502206596\n"
]
}
],
Expand Down Expand Up @@ -133,19 +152,19 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Total happiness \t\t\t = 0.4902676399026764\n",
"Total happiness with recommender \t = 0.6491721614005638\n",
"Total happiness A \t\t\t = 0.4847161572052402\n",
"Total happiness A with recommender \t = 0.6505553012928176\n",
"Total happiness B \t\t\t = 0.49725274725274726\n",
"Total happiness B with recommender \t = 0.6474318370306404\n"
"Total happiness \t\t\t = 0.4926829268292683\n",
"Total happiness with recommender \t = 0.6121423712260986\n",
"Total happiness A \t\t\t = 0.4909090909090909\n",
"Total happiness A with recommender \t = 0.5937602916700374\n",
"Total happiness B \t\t\t = 0.49473684210526314\n",
"Total happiness B with recommender \t = 0.6334268843962747\n"
]
}
],
Expand Down Expand Up @@ -201,15 +220,15 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Happiness first part \t = 0.2347856359841381\n",
"Happiness second part \t = 0.17478925298500678\n"
"Happiness first part \t = 0.224683757843183\n",
"Happiness second part \t = 0.1633900668621427\n"
]
}
],
Expand Down Expand Up @@ -260,7 +279,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 58d11ff

Please sign in to comment.