Skip to content

Instantly share code, notes, and snippets.

View ikanez's full-sized avatar

Hafidz Zulkifli ikanez

View GitHub Profile
C:\Users\UserName>activate tensorflow-gpu
(tensorflow-gpu) C:\Users\UserName>jupyter
usage: jupyter-script.py [-h] [--version] [--config-dir] [--data-dir]
[--runtime-dir] [--paths] [--json]
[subcommand]
jupyter-script.py: error: one of the arguments --version subcommand --config-dir --data-dir --runtime-dir --paths is required
(tensorflow-gpu) C:\Users\UserName>jupyter notebook
[I 01:02:35.990 NotebookApp] [nb_conda_kernels] enabled, 4 kernels found
conda create --name tensorflow-gpu python=3.5
activate tensorflow-gpu
conda install jupyter
conda install scipy
pip install tensorflow-gpu
conda create --name tensorflow python=3.5
activate tensorflow
conda install jupyter (this might fail due to :PaddingError: Placeholder of length '30' too short in package qt-5.6.2-vc14_0.% The package must be rebuilt with conda-build > 2.0. Try running 'conda update --all' in root env, and running it again)
conda install scipy
pip install tensorflow
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-37-16682764c468> in <module>()
----> 1 fit(m, md, 1, lo.opt, F.binary_cross_entropy)
2 # use F.binary_cross_entropy for multi-label problems
~\Dropbox\3.SelfStudy\fastai_pytorch\fastai\courses\dl1\fastai\model.py in fit(model, data, epochs, opt, crit, metrics, callbacks, **kwargs)
104 i += 1
105
--> 106 vals = validate(stepper, data.val_dl, metrics)
@ikanez
ikanez / tracking_param.py
Last active July 13, 2019 01:25
Tracking parameters for MLflow
for param in parameters_list:
# start mlflow run
with mlflow.start_run(run_name='arima_param'):
# log parameters
mlflow.log_param('param-qs', param[0])
mlflow.log_param('param-ps', param[1])
try:
model = SARIMAX(btc_month.close_box, order=(param[0], d, param[1])).fit(disp=-1)
@ikanez
ikanez / importing_mlflow.py
Created July 13, 2019 01:26
Importing mlflow library
import os
import mlflow
import mlflow.sklearn
# Set the experiment name to an experiment
mlflow.set_experiment("/Shared/experiments/cryptocurrency/analysis-forecasting-1")
@ikanez
ikanez / sarimax_model_param.py
Created July 13, 2019 17:26
Find best parameter for sarimax model and log useful stuff into MLflow
# Initial approximation of parameters
Qs = range(0, 2)
qs = range(0, 3)
Ps = range(0, 3)
ps = range(0, 3)
D=1
d=1
parameters = product(ps, qs, Ps, Qs)
parameters_list = list(parameters)
len(parameters_list)
@ikanez
ikanez / sarima_backtest_mlflow.py
Created July 13, 2019 19:41
Evaluate performance of best sarima model over multiple time window and log into mlflow
from datetime import timedelta
num_window = 10
def last_day_of_month(any_day):
next_month = any_day.replace(day=28) + timedelta(days=4) # this will never fail
return next_month - timedelta(days=next_month.day)
with mlflow.start_run(run_name='sarima_backtest'):
t1 = pd.to_datetime('2017-01-31')
@ikanez
ikanez / qa-banking-context.py
Created May 17, 2021 14:30
Prompting the GPT-3 with "banking" context.
def call_openapi(question):
response = openai.Completion.create(
engine="davinci",
prompt="""
This is a banking expert.
Q: What is interest rate?
A: The interest rate is the amount a lender charges for the use of assets expressed as a percentage of the principal.
Q: What is PD?
@ikanez
ikanez / gpt3-job-specialization.py
Created May 17, 2021 14:36
Prompting GPT-3 with job titles, description, and expected syntax of job category/specialization
def call_openapi(title, desc):
response = openai.Completion.create(
engine="davinci",
prompt="""This is a job specialization classifier
Job title: Account Executive
Job description: Handle full set of accounts.\n
Familiar with Income Tax filing.\n
Maintain daily cash flow and reporting.\n
Prepare monthly and annual financial reports.\n