This file contains hidden or 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
# download daily crypto prices from Yahoo Finance | |
df = yf.download(tickers=f'{select_token}-{select_fiat}', period = '1d', interval = '1m') | |
# Plotly line chart | |
fig = go.Figure() | |
fig.add_scattergl(x=df.index, y=df.Close, | |
line={'color': 'green'},name='Up trend') | |
fig.add_scattergl(x=df.index, y=df.Close.where(df.Close <= df.Open[0]), | |
line={'color': 'red'},name='Down trend') | |
fig.add_hline(y=df.Open[0]) |
This file contains hidden or 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 yfinance as yf | |
import pandas as pd | |
import plotly.graph_objs as go | |
# download 5 year crypto prices from Yahoo Finance | |
df = yf.download(tickers='BTC-USD', period = '5y', interval = '1d') | |
# compute moving averages | |
df['MA100'] = df.Close.rolling(100).mean() | |
df['MA50'] = df.Close.rolling(50).mean() |
This file contains hidden or 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
#------------------- | |
# Web scraping Yahoo Finance | |
#------------------- | |
from bs4 import BeautifulSoup | |
import requests | |
import pandas as pd | |
dic = {} | |
url = 'https://finance.yahoo.com/cryptocurrencies?offset=0&count=100' | |
soup = BeautifulSoup(requests.get(url).text) |
This file contains hidden or 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 torch | |
import pandas as pd | |
import networkx as nx | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch_geometric.transforms as T | |
from torch_geometric.nn import ChebConv | |
from torch_geometric.data import InMemoryDataset, Data | |
from sklearn.model_selection import train_test_split |
This file contains hidden or 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 numpy as np | |
import pandas as pd | |
from sklearn.model_selection import train_test_split | |
from sklearn.ensemble import RandomForestClassifier | |
from sklearn import metrics | |
# read data | |
classes = pd.read_csv("../input/elliptic-data-set/elliptic_bitcoin_dataset/elliptic_txs_classes.csv") | |
edgelist = pd.read_csv("../input/elliptic-data-set/elliptic_bitcoin_dataset/elliptic_txs_edgelist.csv") | |
features = pd.read_csv("../input/elliptic-data-set/elliptic_bitcoin_dataset/elliptic_txs_features.csv", header=None) |
This file contains hidden or 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 plotly.express as px | |
import imageio | |
# removing small countries and NA values | |
geo = shapefile.dropna() | |
geo = geo.reset_index(drop=True) | |
geo = geo[['iso3','name','geometry']] | |
# appending temperature values to geo DF | |
for i in range(df_temp.shape[0]): |
This file contains hidden or 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 datetime | |
import geopandas as gpd | |
import pandas as pd | |
import numpy as np | |
from shapely.geometry import mapping | |
import rioxarray | |
# read shapefile | |
shapefile = gpd.read_file("data/world-administrative-boundaries/world-administrative-boundaries.shp") |
This file contains hidden or 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 xarray as xr | |
ds = xr.open_dataset('2mtemp_2021.nc') | |
ds = ds.resample(time='M').mean() #resample monthly | |
#bounds | |
min_lon = -128 | |
min_lat = 19 | |
max_lon = -67 | |
max_lat = 50 |
This file contains hidden or 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
embedding_dim = 100 | |
optimizer = best_params['optimizer'] | |
model = Sequential() | |
model.add(layers.Embedding(input_dim=vocab_size, | |
output_dim=embedding_dim, | |
input_length=maxlen)) | |
model.add(SpatialDropout1D(0.4)) | |
model.add(LSTM(64, activation="tanh")) | |
model.add(Dense(3,activation='softmax')) |
This file contains hidden or 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 optuna | |
from optuna.trial import TrialState | |
from sklearn.metrics import accuracy_score | |
def objective(trial): | |
optimizer_name = trial.suggest_categorical("optimizer", ["adam", "SGD", "RMSprop", "Adadelta"]) | |
epochs = trial.suggest_int("epochs", 5, 15,step=5, log=False) | |
batchsize = trial.suggest_int("batchsize", 8, 40,step=16, log=False) | |
history, model = lstm(optimizer_name,epochs,batchsize) |