Skip to content

Instantly share code, notes, and snippets.

View rohithteja's full-sized avatar

Rohith Teja M rohithteja

  • CEA (Commissariat à l'énergie atomique et aux énergies alternatives)
  • Paris
View GitHub Profile
@rohithteja
rohithteja / dailytrend.py
Created March 11, 2022 14:39
Daily trend line chart Plotly
# 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])
@rohithteja
rohithteja / candlestick.py
Created March 11, 2022 14:37
Candle stick chart Plotly
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()
@rohithteja
rohithteja / webscrape.py
Created March 11, 2022 13:43
Web scraper for Yahoo Finance
#-------------------
# 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)
@rohithteja
rohithteja / elliptic_gcn.py
Last active March 20, 2022 13:44
elliptic GCN model
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
@rohithteja
rohithteja / elliptic_rf.py
Last active March 20, 2022 13:43
elliptic RF model
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)
@rohithteja
rohithteja / choropleth.py
Last active November 1, 2022 10:43
choropleth map
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]):
@rohithteja
rohithteja / clip.py
Last active February 21, 2022 19:20
Clipping over shapefile
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")
@rohithteja
rohithteja / interp.py
Last active February 21, 2022 15:28
interpolate netcdf
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
@rohithteja
rohithteja / lstm-setweights.py
Created August 23, 2021 18:12
Set Weights LSTM
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'))
@rohithteja
rohithteja / lstm-optuna.py
Last active June 21, 2022 11:37
Optuna LSTM
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)