Widespread Augmented Reality

Widespread Augmented Reality
Click on the image to get the Android Augmented Reality Heads up Display

Monday, October 28, 2019

Augmented Reality Heads Up Display

Communicate anonymously through an augmented reality heads up display for Android only. Download app from Google Play.

Sunday, September 8, 2019

Python Machine Learning on Amazon stock prices

This Python code reads Amazon's historical stock prices from 2014 to 2019. I downloaded the CSV file from Yahoo Finance. The chart below shows how well this algorithm predicts stocks prices when compared to actual stock prices. The code was cobbled together from snippets at Analytics Vidhya and Medium.

# importing libraries
import pandas as pd
import numpy as np
from datetime import date, datetime
import calendar
#importing required libraries
from sklearn.preprocessing import MinMaxScaler
from keras.models import Sequential
from keras.layers import Dense, Dropout, LSTM
# reading the data df = pd.read_csv('amzn2.csv')
# looking at the first five rows of the data
print('\n Original data:')
print(df.head())
print('\n Shape of original data:')
print(df.shape)
# setting the index as date
df['Date'] = pd.to_datetime(df.Date,format='%Y-%m-%d')
df.index = df['Date']
#creating dataframe
data = df.sort_index(ascending=True, axis=0)
new_data = pd.DataFrame(index=range(0,len(df)),columns=['Date', 'Close'])
#populate new data frame
for i in range(0,len(data)):
new_data['Date'][i] = data['Date'][i]
new_data['Close'][i] = data['Close'][i]
#setting index
new_data.index = new_data.Date
new_data.drop('Date', axis=1, inplace=True)
#creating train and test sets
dataset = new_data.values
#the csv file has 1260 records
train = dataset[0:630,:]
valid = dataset[630:,:]
#converting dataset into x_train and y_train
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_data = scaler.fit_transform(dataset)
x_train, y_train = [], []
for i in range(60,len(train)):
x_train.append(scaled_data[i-60:i,0])
y_train.append(scaled_data[i,0])
x_train, y_train = np.array(x_train), np.array(y_train)
x_train = np.reshape(x_train, (x_train.shape[0],x_train.shape[1],1))
# create and fit the LSTM network
model = Sequential()
model.add(LSTM(units=50, return_sequences=True, input_shape=(x_train.shape[1],1)))
model.add(LSTM(units=50))
model.add(Dense(1))
model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(x_train, y_train, epochs=1, batch_size=1, verbose=2)
#predicting 246 values, using past 60 from the train data
inputs = new_data[len(new_data) - len(valid) - 60:].values
inputs = inputs.reshape(-1,1)
inputs = scaler.transform(inputs)
X_test = []
for i in range(60,inputs.shape[0]):
X_test.append(inputs[i-60:i,0])
X_test = np.array(X_test)
X_test = np.reshape(X_test, (X_test.shape[0],X_test.shape[1],1))
closing_price = model.predict(X_test)
closing_price = scaler.inverse_transform(closing_price)
rms=np.sqrt(np.mean(np.power((valid-closing_price),2)))
print('\n Root Mean Square Deviation:')
print(rms)
#for plotting
#plot
import matplotlib.pyplot as plt
train = new_data[:630]
valid = new_data[630:]
valid['Predictions'] = closing_price
plt.plot(train['Close'])
plt.plot(valid[['Close','Predictions']])
plt.show()

Wednesday, July 17, 2019

Victory Cross Country 2011 motorcycle stalling

Came to a stop okay, but then accelerated and the bike stalled like it was flooded but it's fuel injection. Rolled to a stop on a downwill slope and reastarted briefly. The engine light was on and it stalled again, never to restart. Battery working as evidenced by lights being on and pump priming. The culprit was a busted and dangling tip over sensor that cuts off the fuel supply when bike is on its side. Since the tip over sensor broke off and was dangling upside down, the bike was going no where fast. Must replace tip over sensor. Found one here.

Thursday, June 27, 2019

Python and MySQL on the Kindle Fire HD 6 inch

  • I got a QPython IDE from here: ww.appsapk.com/qpython-python-for-android
  • MySQL and PHPMyAdmin came from here: www.apkfiles.com/apk-541908/android-web-server-kickweb-server-5-0
  • From pip console in the QPython app, I ran "pip install mysql-connector --index-url https://qpypi3.qpython.org/simple/.
  • At the time that you read this, the links may have changed, but the approach will be the same. Find a QPython apk that you can download from outside of Google Play, see if you can use the PIP console to install AI libraries, adjust the QPypi url in the settings if needed, get a web server app with MySQL and PHP, try to install mysql-connector and finally use the IDE to run data analysis on what ever you import into MySQL and scrub. There is a lot of hit and miss, because of the various apks that may be Chinese or Google versions and neither will work. You must find pure Android apks.

    You may also need a fire extinguisher for when the Kindle Fire really does become fire and explodes while running all your clever little machine learning algorithms.

    Tuesday, June 25, 2019

    Friday, June 7, 2019

    Python - Read MySQL Table and Format Output

    # Using phpadmin to load mysql by importing from some of these sources
    # http://www.cboe.com/delayedquote/quote-table
    # https://datashop.cboe.com/option-quotes-end-of-day-with-calcs
    # https://www.stock-data-solutions.com/download.htm
    # https://www.worldtradingdata.com/services
    import mysql.connector
    optionsdb = mysql.connector.connect(
     host="localhost",
     user="root",
     #passwd=""
     database="CSV_DB"
     )
    optionscursor = optionsdb.cursor()
    optionscursor.execute("select convert(`expiration`, CHAR) as expiration, `option_type` as `T`,
    convert(`strike`, CHAR) as `strike`, convert(`delta_1545`, CHAR) as `delta`, convert(`vega_1545`,
    CHAR) as `vega`, convert(`theta_1545`, CHAR) as `theta` FROM `GREEKS` where `open_interest` > 50 and
    ABS(`delta_1545`) > .20 and ABS(`theta_1545`) < 1
    order by `expiration` asc, `option_type` asc, `strike` asc limit 100") optionsresult = optionscursor.fetchall() colheaders = [] colwidths = [] coldivider = '|' colseparator = '+' for names in optionscursor.description: colwidths.append(11) colheaders.append(names[0]) for w in colwidths: coldivider += " %-"+"%ss |" % (w,) colseparator += '-'*w + '--+' print(colseparator) print(coldivider % tuple(colheaders)) print(colseparator) for coldata in optionsresult: print(coldivider % coldata)

    After running, one may get something that looks like this: