def __init__(self):
        """
        Set up algorithm environment.
        Load:
            Global variables
            Underlying data for algorithm:
                List of hospitals
                Patients by LSOA
                Travel matrix from all LSOA to all hospitals
        """
        # Set up class instances (one instance per class)
        self.data = Data()
        self.pop = Pop()
        self.time_of_last_save = 0

        return
示例#2
0
def main():
    from classes.request import Request
    from classes.data import Data

    import sys

    name = sys.argv[1]

    req = Request(name=name)

    json = req.get_json_by_name()

    d = Data(json)
    d.parse_json()
    print d.get_needed_data()
示例#3
0
def main():
	from classes.request import Request
	from classes.data import Data

	import sys
	from datetime import datetime
	import time

	try:
		lat = sys.argv[1]
		lon = sys.argv[2]
	except:
		# Default NYC coordinates.
		lat = 40
		lon = -74

	req = Request(lat=lat, lon=lon)

	print "Uploading coordinates.."

	while True:
		now = datetime.now()
		hour = now.hour
		minute = now.minute

		if not hour % 3 and not minute:
			# If 0, 3, 6, 9, 12 hours and 0 minute

			res = req.get_json_by_coords()

			data = Data(json=res)
			data.parse_json()

			print data.get_needed_data()

		else:
			print "Waiting for next data.."

		time.sleep(60)
示例#4
0
    def get_all_season(url):

        headers = {
            "User-Agent":
            "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
        }

        html = requests.get(url, headers=headers)
        soup = bs(html.content, features="html.parser")

        player = soup.select('.dataMain > .dataTop > .dataName > h1')[0].text

        player = f"name:{player}"

        table = soup.select(
            '.responsive-table > .grid-view > .items > tbody')[0]
        profile = soup.select('.dataContent > .dataBottom > .dataDaten')
        ribbon = soup.select('.dataRibbon > a')

        if len(ribbon) > 0:
            ribbon = ribbon[0]['title']

        player_bio = []
        country = []
        for items in profile:
            for p in items.find_all('p'):
                for datavalue in p.find_all(
                        True, {"class": re.compile("^(dataValue)$")}):
                    if len(datavalue.find_all('img')) > 0:
                        country.append(datavalue.find_all('img')[0]['title'])

                bio_data = Text.format_text(p.text)
                player_bio.append(bio_data)

        player_bio.append(player)
        bio = Data.get_bio(player_bio, country)

        stats = []
        try:
            for cells in table.find_all(True,
                                        {"class": re.compile("^(even|odd)$")}):
                season = cells.find_all('td')[0].text
                league = cells.find_all(
                    'td')[1].img['title'] if cells.find_all(
                        'td')[1].img else ''
                club = cells.find_all('td')[3].img['alt']
                squad = cells.find_all('td')[4].text
                apps = cells.find_all('td')[5].a.text
                goals = cells.find_all('td')[7].text
                assists = cells.find_all('td')[8].text

                stats_item = {
                    'season': season,
                    'league': league,
                    'club': club,
                    'squad': squad,
                    'apps': apps,
                    'goals': goals,
                    'assists': assists,
                }

                stats.append(stats_item)
        except IndexError:
            pass

        return stats, bio, ribbon
示例#5
0
        'photo':
        'https://s3.amazonaws.com/charitycdn/cache/resizedcrop-75af4d5fd8443d70b4a3d1334d544466-800x800.jpg',
        'profile':
        'https://www.transfermarkt.com.br/kylian-mbappe/leistungsdaten/spieler/342229/plus/0?saison=2018',
        'text':
        '2018/2019 Season',
        'filter':
        'Ligue 1',
        'club': [
            'https://tmssl.akamaized.net/images/wappen/head/583.png?lm=1472229265'
        ]
    },
    {
        'photo':
        'https://bolavip.com/__export/1586720363168/sites/bolavip/img/2020/04/12/edinson-cavani-psg-bordeaux-ligue-1-09022019_defwkc58a8t61ipd1wlkohwji_crop1586720344691.jpg_423682103.jpg',
        'profile':
        'https://www.transfermarkt.com/edinson-cavani/leistungsdaten/spieler/48280/plus/0?saison=2017',
        'text':
        '2017/2018 Season',
        'filter':
        'Ligue 1',
        'club': [
            'https://tmssl.akamaized.net/images/wappen/head/583.png?lm=1472229265'
        ]
    },
]

for player in players:
    Data.set_data(player)
    Playerstats.save(player['photo'], player['profile'], player['text'],
                     player['filter'], player['club'], 'liga_1_scorers')
示例#6
0
from classes.chain import Chain
from classes.block import Block
from classes.data import Data

from datetime import datetime

chain = Chain()

data = Data("senderKey", "receiverKey", 123456, datetime)
block = Block(1, None, data)

chain.addNewBlock(block)

print(chain.isChainValid())
示例#7
0
from classes.human import Human
from classes.data import Data
from classes.controller import Controller
from sys import argv
from matplotlib import pyplot

if __name__ == '__main__':
    if argv[1] != "--help" and argv[1] != "-h":
        name = "spolki/" + argv[1]
        data = Data(name)
        human = Human(data)
        stock = None

        if len(argv) == 3:
            stock = Controller(data, human, int(argv[2]))  # Jesli argv[3] = 1 to Controller uzyje uzyje lekko
            # ulepszonej wersji wskaźnika a jesli argv[3] > 1 to ulepszonej wersji
        else:
            stock = Controller(data, human)

        stock.stock()

        date = data.getDate()
        # pyplot.figure("Project")
        # pyplot.subplot(2, 1, 1)
        # pyplot.plot(date, data.getClose(), label="Price", color="green")
        # pyplot.ylabel("Price in USD")
        # pyplot.xlabel("Date in yyyy-mm-dd format")
        # pyplot.title("Price")
        # pyplot.legend()
        # pyplot.grid(True)
        # pyplot.subplot(2, 1, 2)
示例#8
0
def main():
    while True:
        table = Table(title="Menu")
        table.add_column("Selection",
                         justify="center",
                         style="white",
                         no_wrap=True)
        table.add_column("Action", justify="left", style="yellow")
        table.add_row("1.", "Load data")
        table.add_row("2.", "Explore data")
        table.add_row("3.", "Predict future")
        table.add_row("4.", "Display results")
        table.add_row("5.", "Predict without backtesting")
        table.add_row("0.", "Exit")
        console = Console()
        console.print(table)

        __choose_menu = int(input("Enter your choice: "))
        if __choose_menu == 1:
            user = input("Enter Stock ticker: ")
            start_date = input("Enter start date yyyy-mm-dd: ")
            end_date = input("Enter end date yyyy-mm-dd: ")
            ratio = float(
                input(
                    "Percentage of how much data should be predicted (0-1), \ne.g. 0.95 indicates that 5% of provided data will be predicted: "
                ))
            dataset = Data(f'{user}', f'{start_date}', f'{end_date}', ratio)
            dataset.load_data()
        elif __choose_menu == 2:
            explore = Explore(dataset.original_data()['Adj Close'])
            explore.time_series_decomposition(3)
        elif __choose_menu == 3:
            future = Prophesy(dataset.load_data(), dataset.get_periods())
            future.predict_future()
        elif __choose_menu == 4:
            results = Backtest(dataset.get_all_returns(),
                               future.get_predictions())
            results.print_graph()
            results.error_graph()
        elif __choose_menu == 5:
            user = input("Enter Stock ticker: ")
            future_days = int(input("Enter days to predict: "))
            start_date = input("Enter start date yyyy-mm-dd: ")
            end_date = input("Enter end date yyyy-mm-dd: ")
            dataset = Data(f'{user}', f'{start_date}', f'{end_date}', 1)
            dataset.load_data()
            future = Prophesy(dataset.get_prepared_data(), future_days)
            results = future.predict_future()
            future.plot_result(results)
            future.plot_only_predictions(results, future_days)
        elif __choose_menu == 0:
            exit(0)
        else:
            print("Invalid Choice")