This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import time | |
from datetime import datetime, timedelta | |
import datetime as dt | |
from datetime import date | |
data = {'col': ['id','Number of Days']} | |
ColumnList=pd.DataFrame(data=data) | |
today = date(2018, 6, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sklearn.preprocessing import MinMaxScaler | |
#Import File | |
your_dataset= pd.read_excel("Path\\FileName.xlsx") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Normalize variables between 0 & 1 | |
VariableList = ['Number of Guests','Number of Bedrooms','Latitude','Longitude'] | |
normVariableName = ['No_of_Guests_Norm','No_of_beds_norm','latitude_norm','longitude_norm'] | |
scaler = MinMaxScaler() | |
for i in range(0,len(your_dataset)): | |
for j in range(0,len(VariableList)): | |
temp = your_dataset[VariableList[j]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lat = X_test[:,0] | |
lat = lat.reshape((len(lat),1)) | |
lon = X_test[:,1] | |
lon = lon.reshape((len(lon),1)) | |
time = X_test[:,2] | |
time = time.reshape((len(time),1)) | |
print y_test.shape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#split the data | |
X = RawData[[' Latitude (deg)', ' Longitude (deg)', 'time_secs']] | |
X = X.values.reshape((len(X),3)) | |
y = RawData[' Vehicle speed (MPH)'] | |
y = y.values.reshape((len(y),1)) | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.001, random_state=42) | |
#Create the model and predict | |
nn = 40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Create a function to convert time variable to seconds | |
def hms_to_seconds(t): | |
h, m, s = [float(j) for j in t.split(':')] | |
return 3600*h + 60*m + s | |
#Read the raw files and extract the relevant variables | |
RawData = pd.DataFrame() | |
for file in [f for f in os.listdir('C:\Users\lenovo\Desktop\Karishma\Project 2017\OBD\RawData') if f.endswith('.csv')]: | |
filename = 'C:\Users\lenovo\Desktop\Karishma\Project 2017\OBD\RawData\\' + file | |
data = pd.read_csv(filename, skiprows=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import pandas as pd | |
import datetime as dt | |
from os import listdir | |
import os | |
import numpy as np | |
from numpy import mean, sqrt, square, arange | |
import matplotlib.pyplot as plt | |
from sklearn import neighbors | |
from sklearn.model_selection import train_test_split |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Join all the text from the 1000 tweets | |
Hashtag_Combined = " ".join(Htag_df['Hashtag'].values.astype(str)) | |
no_millennials = " ".join([word for word in Hashtag_Combined.split() | |
if word != 'millennials' | |
and word != 'Millennials' | |
and word != 'Boomers' | |
and word != 'GenX' | |
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Htag_df = pd.DataFrame() | |
j = 0 | |
for tweet in range(0,len(results)): | |
hashtag = results[tweet].entities.get('hashtags') | |
for i in range(0,len(hashtag)): | |
Htag = hashtag[i]['text'] | |
Htag_df.set_value(j, 'Hashtag',Htag) | |
j = j+1 |
NewerOlder