Added neural network related things and other maths stuff

This commit is contained in:
2019-03-09 00:38:22 +01:00
parent 879abc9861
commit b670f9a195
15 changed files with 295 additions and 7 deletions
+48 -3
View File
@@ -3,6 +3,12 @@ import matplotlib.pyplot as plt
import csv
import numpy as np
import urllib
import matplotlib.dates as mdates
import sys
print(sys.version)
"""
x=[1,2,3]
@@ -88,14 +94,53 @@ x,y=np.loadtxt("text.txt",delimiter=",",unpack=True)
plt.plot(x,y,label="loaded from file")
"""
def bytespdate2num(fmt,encoding="utf-8"):
strconverter=mdates.strpdate2num(fmt)
def bytesconverter(b):
s=b.decode(encoding)
return strconverter(s)
return bytesconverter
def graph_data(stock):
#fig=plt.figure()
#ax1=plt.subplot2grid((1,1),(0,0))
stock_price_url = 'https://pythonprogramming.net/yahoo_finance_replacement'
plt.xlabel("x")
plt.ylabel("y")
source_code=urllib.request.urlopen(stock_price_url).read().decode()
#print(source_code)
stock_data=[]
split_source=source_code.split('\n')
for line in split_source:
split_line=line.split(",")
if len(split_line)==6:
if 'values' not in line and 'labels' not in line:
stock_data.append(line)
date,closep,highp,lowp,openp,volume=np.loadtxt(stock_data,
delimiter=",",
unpack=True,
#%Y=full year
#%y=partial year
#%m=number month
#%d=day
#%H=hours
#%M=minutes
#%S=seconds
#%m-%d-%Y
#converters={0: bytespdate2num('%Y%m%d')})
converters={0: lambda s : mdates.date2num(datetime.strptime(s.decode("utf-8"),'%Y%m%d'))})
plt.plot_date(date,closep,"-")
plt.xlabel("date")
plt.ylabel("price")
plt.title("Interesting graph\nCheck it out!")
plt.legend()
plt.show()
@@ -0,0 +1,19 @@
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
import random
style.use("fivethirtyeight")
fig=plt.figure()
ax1=fig.add_subplot(1,1,1)
x=[i for i in range(100)]
def animate(i):
y=[random.randint(0,10) for i in range(100)]
ax1.clear()
ax1.plot(x,y)
ani=animation.FuncAnimation(fig,animate,interval=1000)
plt.show()