Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisingh977 committed Apr 20, 2020
1 parent 95236c5 commit 4a4ee41
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def convert_to_categorical(df, categorical_variables, categories, need_pickup =

x = df[['pickup_community_area' ,'temperature', 'relative_humidity', 'wind_direction', 'wind_speed', 'precipitation_cat',
'sky_level', 'daytype', 'Day Name', 'Month', 'Hour', 'Fare Last Month', 'Trips Last Hour',
'Trips Last Week (Same Hour)', 'Trips 2 Weeks Ago (Same Hour)', 'Quarter', 'Year', 'trip_start_timestamp']]
'Trips Last Week (Same Hour)', 'Trips 2 Weeks Ago (Same Hour)', 'Year', 'trip_start_timestamp']]

categorical_variables = ['pickup_community_area', 'daytype', 'sky_level', 'Day Name', 'Month','Hour', 'Year']
categories = [[*(range(1,78))], ['U', 'W', 'A'], ['OVC', 'BKN', 'SCT', 'FEW', 'CLR', 'VV '],
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/models/regression/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def convert_to_categorical(df, categorical_variables, categories, need_pickup =

x = df[['pickup_community_area' ,'temperature', 'relative_humidity', 'wind_direction', 'wind_speed', 'precipitation_cat',
'sky_level', 'daytype', 'Day Name', 'Month', 'Hour', 'Fare Last Month', 'Trips Last Hour',
'Trips Last Week (Same Hour)', 'Trips 2 Weeks Ago (Same Hour)', 'Quarter', 'Year', 'trip_start_timestamp']]
'Trips Last Week (Same Hour)', 'Trips 2 Weeks Ago (Same Hour)', 'Year', 'trip_start_timestamp']]

categorical_variables = ['pickup_community_area', 'daytype', 'sky_level', 'Day Name', 'Month','Hour', 'Year']
categories = [[*(range(1,78))], ['U', 'W', 'A'], ['OVC', 'BKN', 'SCT', 'FEW', 'CLR', 'VV '],
Expand Down
90 changes: 86 additions & 4 deletions src/models_helper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"df = df.drop(columns=['Unnamed: 0'],axis=1)"
]
"source": []
},
{
"cell_type": "code",
Expand Down Expand Up @@ -301,7 +299,91 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"# Gradientboost\n",
"model_Gradientboost = joblib.load(path_datasets+\"/model/GBR.pickle\")\n",
"\n",
"path_to_model = pathToSrc + f'{sep}models{sep}/Gradientboost/Gradientboost.py'\n",
"spec = importlib.util.spec_from_file_location(\"Gradientboost\", path_to_model)\n",
"Gradientboost = importlib.util.module_from_spec(spec)\n",
"spec.loader.exec_module(Gradientboost)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"date = \"2019-11-16 16:00:00\"\n",
"#getDate from request.form.values:\n",
"#row = df[df['trip_start_timestamp'] == date].iloc[0,]\n",
"\n",
"# Transform to array X\n",
"X = Gradientboost.TransformDataToX(df, date)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Predict\n",
"Y = model_Gradientboost.predict(X)\n",
"#prediction = np.random.randint(1,200,77)\n",
"# Create map\n",
"\n",
"prediction = Gradientboost.TransformYToResult(Y)\n",
"\n",
"# Create map\n",
"mp.mapGenerator(prediction)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Liner_Regression\n",
"model_regression = joblib.load(path_datasets+\"/model/reg.pickle\")\n",
"\n",
"path_to_model = pathToSrc + f'{sep}models{sep}/regression/regression.py'\n",
"spec = importlib.util.spec_from_file_location(\"regression\", path_to_model)\n",
"regression = importlib.util.module_from_spec(spec)\n",
"spec.loader.exec_module(regression)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"date = \"2019-11-16 16:00:00\"\n",
"\n",
"# Transform to array X\n",
"X = regression.TransformDataToX(df, date)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Predict\n",
"Y = model_regression.predict(X)\n",
"#prediction = np.random.randint(1,200,77)\n",
"# Create map\n",
"\n",
"prediction = regression.TransformYToResult(Y)\n",
"\n",
"# Create map\n",
"mp.mapGenerator(prediction)"
]
}
],
"metadata": {
Expand Down

0 comments on commit 4a4ee41

Please sign in to comment.