[Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-16 Thread Allan Tanaka via Tutor
Not completely sure why it doesn't open the chart on the web browser when i 
type this in the windows command prompt (cmd) python -m SimpleHTTPServer port 
80.So first i type python ml.py data/sample.csv in cmd windows and then python 
-m SimpleHTTPServer port 80, but it's not proceeding to the graph in html??
See attached image for screenshoot and complete .py file

"""
Find the support/resistance lines in a chart

JonV / May 16 2015
"""

import sys
import pandas
import numpy as np
import json
from sklearn.cluster import MeanShift, estimate_bandwidth


def main(filename):
# read csv files with daily data per tick
df = pandas.read_csv('sample.csv', parse_dates=[0], index_col=0, 
names=['Date_Time', 'Buy', 'Sell'],
 date_parser=lambda x: pandas.to_datetime(x, 
format="%d/%m/%y %H:%M:%S"))

# group by day and drop NA values (usually weekends)
grouped_data = df.dropna()
ticks_data = grouped_data['Sell'].resample('24H').ohlc()

# use 'ask'
sell_data = grouped_data.as_matrix(columns=['Sell'])

# calculate bandwidth (expirement with quantile and samples)
bandwidth = estimate_bandwidth(sell_data, quantile=0.1, n_samples=100)
ms = MeanShift(bandwidth=bandwidth, bin_seeding=True)

# fit the data
ms.fit(sell_data)

ml_results = []
for k in range(len(np.unique(ms.labels_))):
my_members = ms.labels_ == k
values = sell_data[my_members, 0]

# find the edges
ml_results.append(min(values))
ml_results.append(max(values))

# export the data for the visualizations
ticks_data.to_json('ticks.json', date_format='iso', orient='index')

# export ml support resisistance
with open('ml_results.json', 'w') as f:
f.write(json.dumps(ml_results))


print "Done. Goto 0.0.0.0:8000/chart.html"

if __name__ == "__main__":
if (len(sys.argv) < 2):
print 'ml.py '
sys.exit(2)
main(sys.argv[1])


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] [Python 2.7] HELP: Serving HTTP on 0.0.0.0 port 80 not proceeding

2017-02-16 Thread Alan Gauld via Tutor
There are several issues here, I'll try to address
them separately below...

On 16/02/17 13:26, Allan Tanaka via Tutor wrote:
> Not completely sure why it doesn't open the chart on the web browser 

You haven't shown us chart.html so we can't guess how your data
in ticks.json is supposed to get into charts.html to be displayed.
Does ticks.json exist and does it look like you expect?
If so its probably not a Python problem but a web one.

> when i type this in the windows command prompt (cmd) 
> python -m SimpleHTTPServer port 80.

Your code says you are using port 8000:

print "Done. Goto 0.0.0.0:8000/chart.html"

Which is it?

> So first i type python ml.py data/sample.csv in cmd 
> windows and then python -m SimpleHTTPServer port 80, 
> but it's not proceeding to the graph in html??
> 

> See attached image for screenshoot and complete .py file

This is a text based list so attachments, especially
binary files like images,  are usually strippped out.
I can see the .py file but that's all. Can you post
the image on a web site somewhere and send a link?
Or if its text just cut n paste into a mail?

I can't really comment much as its mostly numpy, pandas
and sklearn code which are all a bit off-topic for
this list.

But we need a bit more about the environment to
figure out where the issue lie.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor