Compare commits

...

6 Commits

Author SHA1 Message Date
c0fed7c932 Removed jupyter notebook outputs 2022-12-22 18:35:20 +01:00
f92c3d07f1 Reinserted last row in training data 2022-12-22 18:34:41 +01:00
70cab97cfc Updated similarity matrices 2022-12-22 18:33:49 +01:00
28d17d5c35 Improved query 2022-12-22 17:39:16 +01:00
b32c86c302 Added .gitignore 2022-12-22 17:38:51 +01:00
fe104fe738 Added task pdf 2022-12-22 17:38:39 +01:00
9 changed files with 50 additions and 91 deletions

5
.gitignore vendored
View File

@ -1,5 +1,2 @@
__pycache__
*/__pycache__
*sublime*
env/
venv/ venv/
__pycache__

BIN
KI_PE20_SIM_1.pdf Normal file

Binary file not shown.

View File

@ -498,3 +498,4 @@
23;24;20;-76;45;truck;truck;3537;ascending;country_road (separated);day;dry;car;120;continue 23;24;20;-76;45;truck;truck;3537;ascending;country_road (separated);day;dry;car;120;continue
25;35;23;-67;49;sportscar;truck;4248;flat;country_road (separated);day;rain;car;100;continue 25;35;23;-67;49;sportscar;truck;4248;flat;country_road (separated);day;rain;car;100;continue
22,5;24,5;28,5;-175;36;car;car;1512;flat;country_road (separated);day;dry;truck;100;continue 22,5;24,5;28,5;-175;36;car;car;1512;flat;country_road (separated);day;dry;truck;100;continue
22,5;27,5;34,5;-68;40;truck;motorcycle;3285;flat;country_road (separated);day;rain;truck;120;continue
1 v v_left v_front d_left d_front type_left type_front radius_curve(m) slope_street street_type time weather type_vehicle speed_limit(km/h) action
498 23 24 20 -76 45 truck truck 3537 ascending country_road (separated) day dry car 120 continue
499 25 35 23 -67 49 sportscar truck 4248 flat country_road (separated) day rain car 100 continue
500 22,5 24,5 28,5 -175 36 car car 1512 flat country_road (separated) day dry truck 100 continue
501 22,5 27,5 34,5 -68 40 truck motorcycle 3285 flat country_road (separated) day rain truck 120 continue

View File

@ -1,4 +1,4 @@
type_street_slope, flat, ascending, decending type_street_slope, flat, ascending, decending
flat, 1.0, 0.5, 0.6 flat, 1.0, 0.3, 0.7
ascending, 0.5, 1.0, 0.3 ascending, 0.3, 1.0, 0.1
decending, 0.6, 0.3, 1.0 decending, 0.7, 0.1, 1.0
1 type_street_slope flat ascending decending
2 flat 1.0 0.5 0.3 0.6 0.7
3 ascending 0.5 0.3 1.0 0.3 0.1
4 decending 0.6 0.7 0.3 0.1 1.0

View File

@ -1,3 +1,3 @@
type_street, country_road (separated), autobahn type_street, country_road (separated), autobahn
country_road (separated), 1.0, 0.5 country_road (separated), 1.0, 0.3
autobahn, 0.5, 1.0 autobahn, 0.3, 1.0
1 type_street country_road (separated) autobahn
2 country_road (separated) 1.0 0.5 0.3
3 autobahn 0.5 0.3 1.0

View File

@ -1,5 +1,5 @@
type_time, night, dusk, day, dawn type_time, night, dusk, day, dawn
night, 1.0, 0.5, 0.6, 0.8 night, 1.0, 0.5, 0.2, 0.8
dusk, 0.5, 1.0, 0.3, 0.5 dusk, 0.5, 1.0, 0.3, 0.5
day, 0.6, 0.3, 1.0, 0.6 day, 0.2, 0.3, 1.0, 0.6
dawn, 0.8, 0.5, 0.6, 1.0 dawn, 0.8, 0.5, 0.6, 1.0
1 type_time night dusk day dawn
2 night 1.0 0.5 0.6 0.2 0.8
3 dusk 0.5 1.0 0.3 0.5
4 day 0.6 0.2 0.3 1.0 0.6
5 dawn 0.8 0.5 0.6 1.0

View File

@ -1,5 +1,5 @@
type_vehicle, car, motorcycle, sportscar, truck type_vehicle, car, motorcycle, sportscar, truck
car, 1.0, 0.5, 0.6, 0.8 car, 1.0, 0.3, 0.6, 0.3
motorcycle, 0.5, 1.0, 0.3, 0.5 motorcycle, 0.3, 1.0, 0.9, 0.1
sportscar, 0.6, 0.3, 1.0, 0.6 sportscar, 0.6, 0.9, 1.0, 0.2
truck, 0.8, 0.5, 0.6, 1.0 truck, 0.3, 0.1, 0.2, 1.0
1 type_vehicle car motorcycle sportscar truck
2 car 1.0 0.5 0.3 0.6 0.8 0.3
3 motorcycle 0.5 0.3 1.0 0.3 0.9 0.5 0.1
4 sportscar 0.6 0.3 0.9 1.0 0.6 0.2
5 truck 0.8 0.3 0.5 0.1 0.6 0.2 1.0

View File

@ -1,5 +1,5 @@
type_weather, dry, rain, fog, snow_ice type_weather, dry, rain, fog, snow_ice
dry, 1.0, 0.5, 0.6, 0.8 dry, 1.0, 0.4, 0.2, 0.1
rain, 0.5, 1.0, 0.3, 0.5 rain, 0.4, 1.0, 0.8, 0.6
fog, 0.6, 0.3, 1.0, 0.6 fog, 0.2, 0.8, 1.0, 0.4
snow_ice, 0.8, 0.5, 0.6, 1.0 snow_ice, 0.1, 0.6, 0.4, 1.0
1 type_weather dry rain fog snow_ice
2 dry 1.0 0.5 0.4 0.6 0.2 0.8 0.1
3 rain 0.5 0.4 1.0 0.3 0.8 0.5 0.6
4 fog 0.6 0.2 0.3 0.8 1.0 0.6 0.4
5 snow_ice 0.8 0.1 0.5 0.6 0.6 0.4 1.0

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -13,7 +13,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -34,29 +34,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"CaseBase(cases=499, fields=[('v', 'v_left', 'v_front', 'd_left', 'd_front', 'type_left', 'type_front', 'radius_curve(m)', 'slope_street', 'street_type', 'time', 'weather', 'type_vehicle', 'speed_limit(km/h)'), 'action'])\n"
]
},
{
"data": {
"text/plain": [
"[Case(problem={'v_left': 36.5, 'v_front': 23.0, 'd_left': -56.0, 'd_front': 45.0, 'type_left': 'sportscar', 'type_front': 'truck', 'radius_curve(m)': 2237.0, 'slope_street': 'flat', 'street_type': 'country_road (separated)', 'time': 'night', 'weather': 'dry', 'type_vehicle': 'car', 'speed_limit(km/h)': 100.0}, solution={'action': 'continue'}),\n",
" Case(problem={'v_left': 32.0, 'v_front': 28.0, 'd_left': -114.0, 'd_front': 44.0, 'type_left': 'motorcycle', 'type_front': 'car', 'radius_curve(m)': 3891.0, 'slope_street': 'ascending', 'street_type': 'autobahn', 'time': 'night', 'weather': 'dry', 'type_vehicle': 'truck', 'speed_limit(km/h)': 250.0}, solution={'action': 'continue'}),\n",
" Case(problem={'v_left': 43.0, 'v_front': 31.5, 'd_left': -98.0, 'd_front': 60.0, 'type_left': 'truck', 'type_front': 'car', 'radius_curve(m)': 1720.0, 'slope_street': 'flat', 'street_type': 'autobahn', 'time': 'dusk', 'weather': 'rain', 'type_vehicle': 'car', 'speed_limit(km/h)': 130.0}, solution={'action': 'continue'})]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"case_base = CaseBase.from_csv(\n", "case_base = CaseBase.from_csv(\n",
" \"data/SIM_001.csv\",\n", " \"data/SIM_001.csv\",\n",
@ -72,7 +52,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -97,6 +77,11 @@
")\n", ")\n",
"\n", "\n",
"case_base.add_symbolic_sim(\n", "case_base.add_symbolic_sim(\n",
" field = \"street_type\",\n",
" similarity_matrix = create_similarity_matrix(\"data/street_type_sim.csv\", \"type_street\")\n",
")\n",
"\n",
"case_base.add_symbolic_sim(\n",
" field = \"time\",\n", " field = \"time\",\n",
" similarity_matrix = create_similarity_matrix(\"data/time_type_sim.csv\", \"type_time\")\n", " similarity_matrix = create_similarity_matrix(\"data/time_type_sim.csv\", \"type_time\")\n",
")\n", ")\n",
@ -109,53 +94,25 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"Your Query:\n",
" - v = 28\n",
" - v_left = 37\n",
" - v_front = 22.5\n",
" - d_left = -20\n",
" - d_front = 51\n",
" - radius_curve = 2000\n",
" - speed_limit = 200\n",
" - type_vehicle = motorcycle\n",
" - type_left = motorcycle\n",
" - type_front = motorcycle\n",
"\n",
"I recommend you this car:\n",
"Accelerated_lane_change\n",
"\n",
"Explanation:\n",
" - v_left = 37.0 (similarity: 1.00)\n",
" - v_front = 22.5 (similarity: 1.00)\n",
" - d_left = -17.0 (similarity: 0.25)\n",
" - d_front = 51.0 (similarity: 1.00)\n",
" - radius_curve(m) = 3020.0 (similarity: 0.00)\n",
" - speed_limit(km/h) = 120.0 (similarity: 0.01)\n",
" - type_vehicle = car (similarity: 0.50)\n",
" - type_left = truck (similarity: 0.50)\n",
" - type_front = truck (similarity: 0.50)\n"
]
}
],
"source": [ "source": [
"query = Query.from_problems(\n", "query = Query.from_problems(\n",
" v = 28,\n", " v = 28.5,\n",
" v_left = 37,\n", " v_left = 42.5,\n",
" v_front = 22.5,\n", " v_front = 5,\n",
" d_left = -20,\n", " d_left = -137,\n",
" d_front = 51,\n", " d_front = 54,\n",
" radius_curve = 2000,\n",
" speed_limit = 200,\n",
" type_vehicle = \"motorcycle\",\n",
" type_left = \"motorcycle\",\n", " type_left = \"motorcycle\",\n",
" type_front = \"motorcycle\",\n", " type_front = \"truck\",\n",
" radius_curve = 2391,\n",
" slope_street = \"flat\",\n",
" street_type = \"country_road (separated)\",\n",
" time = \"day\",\n",
" weather = \"dry\",\n",
" type_vehicle = \"car\",\n",
" speed_limit = 100,\n",
")\n", ")\n",
"\n", "\n",
"# sim_funcs: manhattan_sim, euclid_sim\n", "# sim_funcs: manhattan_sim, euclid_sim\n",
@ -165,11 +122,15 @@
" v_front = euclid_sim,\n", " v_front = euclid_sim,\n",
" d_left = euclid_sim,\n", " d_left = euclid_sim,\n",
" d_front = euclid_sim,\n", " d_front = euclid_sim,\n",
" radius_curve = manhattan_sim,\n",
" speed_limit = manhattan_sim,\n",
" type_vehicle = symbolic_sim,\n",
" type_left = symbolic_sim,\n", " type_left = symbolic_sim,\n",
" type_front = symbolic_sim,\n", " type_front = symbolic_sim,\n",
" radius_curve = euclid_sim,\n",
" slope_street = symbolic_sim,\n",
" street_type = symbolic_sim,\n",
" time = symbolic_sim,\n",
" weather = symbolic_sim,\n",
" type_vehicle = symbolic_sim,\n",
" speed_limit = euclid_sim,\n",
")\n", ")\n",
"\n", "\n",
"print(\"Your Query:\")\n", "print(\"Your Query:\")\n",
@ -206,7 +167,7 @@
"orig_nbformat": 4, "orig_nbformat": 4,
"vscode": { "vscode": {
"interpreter": { "interpreter": {
"hash": "4c522f398908c053844cc48bcd755f88db468f52081f171c67c4d9e41e8d16a6" "hash": "c6b11de3c41b7cafaa0ac1297b550056ae3875bbf0c337fa48ab4f33656fc527"
} }
} }
}, },