Add 道路同行时间预测

pull/2/head
benjas 4 years ago
parent c8cc67c977
commit 87704aa1fb

@ -0,0 +1,374 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 数据展示"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"from scipy.interpolate import UnivariateSpline\n",
"from sklearn import linear_model\n",
"import xgboost as xgb\n",
"# from ultis import *"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"道路通行时间:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>link_ID</th>\n",
" <th>date</th>\n",
" <th>time_interval</th>\n",
" <th>travel_time</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4377906283422600514</td>\n",
" <td>2017-05-06</td>\n",
" <td>[2017-05-06 11:04:00,2017-05-06 11:06:00)</td>\n",
" <td>3.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>3377906289434510514</td>\n",
" <td>2017-05-06</td>\n",
" <td>[2017-05-06 10:42:00,2017-05-06 10:44:00)</td>\n",
" <td>1.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3377906285934510514</td>\n",
" <td>2017-05-06</td>\n",
" <td>[2017-05-06 11:56:00,2017-05-06 11:58:00)</td>\n",
" <td>35.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3377906285934510514</td>\n",
" <td>2017-05-06</td>\n",
" <td>[2017-05-06 17:46:00,2017-05-06 17:48:00)</td>\n",
" <td>26.2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>3377906287934510514</td>\n",
" <td>2017-05-06</td>\n",
" <td>[2017-05-06 10:52:00,2017-05-06 10:54:00)</td>\n",
" <td>10.4</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" link_ID date time_interval \\\n",
"0 4377906283422600514 2017-05-06 [2017-05-06 11:04:00,2017-05-06 11:06:00) \n",
"1 3377906289434510514 2017-05-06 [2017-05-06 10:42:00,2017-05-06 10:44:00) \n",
"2 3377906285934510514 2017-05-06 [2017-05-06 11:56:00,2017-05-06 11:58:00) \n",
"3 3377906285934510514 2017-05-06 [2017-05-06 17:46:00,2017-05-06 17:48:00) \n",
"4 3377906287934510514 2017-05-06 [2017-05-06 10:52:00,2017-05-06 10:54:00) \n",
"\n",
" travel_time \n",
"0 3.0 \n",
"1 1.0 \n",
"2 35.2 \n",
"3 26.2 \n",
"4 10.4 "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv('new_gy_contest_traveltime_training_data_second.txt',delimiter=';',dtype={'link_ID':object})\n",
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"time_interval时间间隔两分钟为单位\n",
"\n",
"travel_time平均通行时间"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"道理长宽情况:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>link_ID</th>\n",
" <th>length</th>\n",
" <th>width</th>\n",
" <th>link_class</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4377906289869500514</td>\n",
" <td>57</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4377906284594800514</td>\n",
" <td>247</td>\n",
" <td>9</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4377906289425800514</td>\n",
" <td>194</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4377906284525800514</td>\n",
" <td>839</td>\n",
" <td>3</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4377906284422600514</td>\n",
" <td>55</td>\n",
" <td>12</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" link_ID length width link_class\n",
"0 4377906289869500514 57 3 1\n",
"1 4377906284594800514 247 9 1\n",
"2 4377906289425800514 194 3 1\n",
"3 4377906284525800514 839 3 1\n",
"4 4377906284422600514 55 12 1"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"link_df = pd.read_csv('gy_contest_link_info.txt',delimiter=';',dtype={'link_ID':object})\n",
"link_df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"length长度 width宽度 link_class类别"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"道路之间连接情况:"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>link_ID</th>\n",
" <th>in_links</th>\n",
" <th>out_links</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>4377906289869500514</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>4377906284594800514</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>4377906289425800514</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4377906284525800514</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4377906284422600514</td>\n",
" <td>2</td>\n",
" <td>1</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" link_ID in_links out_links\n",
"0 4377906289869500514 1 1\n",
"1 4377906284594800514 1 1\n",
"2 4377906289425800514 1 1\n",
"3 4377906284525800514 1 1\n",
"4 4377906284422600514 2 1"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"link_tops = pd.read_csv('gy_contest_link_top_update.txt',delimiter=',',dtype={'link_ID':object})\n",
"link_tops.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 任务:预测未来一个月平均通行结果,每两分钟一次\n",
"回归任务\n",
"\n",
"构建时间序列,基于前几天或者前几十天的数据预测"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading…
Cancel
Save