emirkaanozdemr commited on
Commit
2f9956d
1 Parent(s): 133ca45

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +33 -0
  2. newyorkcity_model.pkl +3 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pickle
4
+ import math
5
+ def haversine(pickup_longitude, pickup_latitude, dropoff_longitude, dropoff_latitude):
6
+ R = 6371.0
7
+
8
+ phi1 = math.radians(pickup_latitude)
9
+ phi2 = math.radians(dropoff_latitude)
10
+ delta_phi = math.radians(dropoff_latitude - pickup_latitude)
11
+ delta_lambda = math.radians(dropoff_longitude - pickup_longitude)
12
+
13
+ a = math.sin(delta_phi / 2.0)**2 + math.cos(phi1) * math.cos(phi2) * math.sin(delta_lambda / 2.0)**2
14
+ c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
15
+
16
+ distance = R * c
17
+ return distance
18
+ p_lo=st.number_input("Pickup Longitude")
19
+ p_la=st.number_input("Pickup Latitude")
20
+ d_lo=st.number_input("Dropoff Longitude")
21
+ d_la=st.number_input("Dropoff Latitude")
22
+ passenger_count=st.number_input("Passenger Count")
23
+ distance=haversine(p_lo,p_la,d_lo,d_la)
24
+ file_path = 'newyorkcity_model.pkl'
25
+ with open(file_path, 'rb') as file:
26
+ model = pickle.load(file)
27
+ data=[distance,passenger_count]
28
+ if st.button("Predict"):
29
+ data=np.array(data)
30
+ if len(data.shape) == 1:
31
+ data = np.expand_dims(data, axis=0)
32
+ prediction=model.predict(data)
33
+ st.write(prediction)
newyorkcity_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7c5f23114b276ab69ca9128c84bf87df154e14874398f9e33f1106761ba6940
3
+ size 298060
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ numpy
3
+ pickle
4
+ math