NeroCube / bookmark

Place some learning resources
0 stars 0 forks source link

temp #297

Open NeroCube opened 3 years ago

NeroCube commented 3 years ago

Reference

https://blog.gtwang.org/programming/python-beautiful-soup-module-scrape-web-pages-tutorial/

optuna.logging.set_verbosity(optuna.logging.WARNING)
# study = optuna.create_study(
#     direction="maximize",
#     sampler=optuna.samplers.TPESampler(seed=seed),#Sampler using TPE (Tree-structured Parzen Estimator) algorithm.
#     pruner=optuna.pruners.MedianPruner(n_warmup_steps=10),
# )
# study.optimize(objective, n_trials=5000)
# print('Best trial:', study.best_trial.params)
NeroCube commented 3 years ago
score: 123.76645844858173 local score: 59.142787265964174 hold score: 64.62367118261756
-----
['F_2', 'F_9', 'F_1_log_return_amin_220', 'F_1_log_return_realized_volatility_220', 'F_1_diff_140', 'F_2_log_return', 'F_2_log_return_sum_220', 'F_2_diff_10', 'F_2_diff_50', 'F_2_diff140', 'F_2_diff_180', 'F_3_log_return_sum_220', 'F_3_log_return_amax_220', 'F_3_log_return_realized_volatility_220', 'F_3_diff5', 'F_3_diff10', 'F_3_diff_30', 'F_3_diff_50', 'F_3_diff120', 'F_3_diff_140', 'F_3_diff_220', 'F_5_diff_5', 'F_5_diff_120', 'F_5_diff_220', 'F_6_log_return', 'F_6_diff5', 'F_6_diff180', 'F_6_diff_220', 'F_7_log_return_realized_volatility_220', 'F_7_diff_5', 'F_7_diff10', 'F_7_diff_10', 'F_7_diff30', 'F_7_diff_120', 'F_7_diff140', 'F_7_diff_180', 'F_8_log_return_sum_220', 'F_8_log_return_amin_220', 'F_8_diff120', 'F_8_diff140', 'F_8_diff_220', 'F_10_log_return_std_220', 'F_11_log_return_sum_220', 'F_11_log_return_realized_volatility_220', 'F_11_diff_10', 'F_11_diff220', 'F_12_log_return', 'F_12_log_return_sum_220', 'F_12_log_return_std_220', 'F_12_diff10', 'F_12_diff_10', 'F_12_diff220', 'F_12_diff_220', 'F_13_log_return_std_220', 'F_13_log_return_amax_220', 'F_13_diff5', 'F_13_diff_5', 'F_13_diff30', 'F_13_diff_50', 'F_13_diff180', 'F_13_diff_180', 'F_13_diff220']
local mse: 0.3175375469426975
holdout mse: 0.24097073774088315
localLessThanRatio: 0.9999546819237524
localMaxABS: 10.53650292175579
HoldOutLessThanRatio: 1.0
HoldOutMaxABS: 5.376328817382451
-----
score: 124.0566365773885 local score: 59.2579008838068 hold score: 64.7987356935817
-----
['F_2', 'F_9', 'F_1_log_return_amax_220', 'F_1_log_return_amin_220', 'F_1_log_return_realized_volatility_220', 'F_1_diff_140', 'F_2_log_return', 'F_2_diff_10', 'F_2_diff_50', 'F_2_diff140', 'F_2_diff_180', 'F_3_log_return_sum_220', 'F_3_log_return_amax_220', 'F_3_log_return_realized_volatility_220', 'F_3_diff5', 'F_3_diff10', 'F_3_diff_30', 'F_3_diff_50', 'F_3_diff120', 'F_3_diff_140', 'F_3_diff_220', 'F_5_diff_5', 'F_5_diff50', 'F_5_diff_220', 'F_6_log_return', 'F_6_diff5', 'F_6_diff30', 'F_6_diff180', 'F_6_diff_220', 'F_7_log_return_realized_volatility_220', 'F_7_diff_5', 'F_7_diff10', 'F_7_diff_10', 'F_7_diff30', 'F_7_diff_120', 'F_7_diff140', 'F_7_diff_180', 'F_8_log_return_sum_220', 'F_8_log_return_amin_220', 'F_8_diff120', 'F_8_diff140', 'F_8_diff_220', 'F_10_log_return_std_220', 'F_11_log_return_sum_220', 'F_11_log_return_realized_volatility_220', 'F_11_diff_10', 'F_11_diff30', 'F_11_diff_50', 'F_11_diff220', 'F_12_log_return', 'F_12_log_return_sum_220', 'F_12_log_return_std_220', 'F_12_diff10', 'F_12_diff_120', 'F_12_diff140', 'F_12_diff220', 'F_13_log_return_sum_220', 'F_13_log_return_std_220', 'F_13_log_return_amax_220', 'F_13_diff5', 'F_13_diff_5', 'F_13_diff30', 'F_13_diff_50', 'F_13_diff120', 'F_13_diff180', 'F_13_diff_180', 'F_13_diff220']
local mse: 0.33689907878970315
holdout mse: 0.2535801519033703
localLessThanRatio: 0.9999773409618762
localMaxABS: 10.403613904734833
HoldOutLessThanRatio: 1.0
HoldOutMaxABS: 5.201264306418302
-----
NeroCube commented 3 years ago

['F_2', 'F_9', 'F_1_log_return_amax_220', 'F_1_log_return_amin_220', 'F_1_log_return_realized_volatility_220', 'F_1_diff_140', 'F_2_log_return', 'F_2_diff_10', 'F_2_diff_50', 'F_2_diff140', 'F_2_diff_180', 'F_3_log_return_sum_220', 'F_3_log_return_amax_220', 'F_3_log_return_realized_volatility_220', 'F_3_diff5', 'F_3_diff10', 'F_3_diff_30', 'F_3_diff_50', 'F_3_diff120', 'F_3_diff_140', 'F_3_diff_220', 'F_5_diff_5', 'F_5_diff50', 'F_5_diff_220', 'F_6_log_return', 'F_6_diff5', 'F_6_diff30', 'F_6_diff180', 'F_6_diff_220', 'F_7_log_return_realized_volatility_220', 'F_7_diff_5', 'F_7_diff10', 'F_7_diff_10', 'F_7_diff30', 'F_7_diff_120', 'F_7_diff140', 'F_7_diff_180', 'F_8_log_return_sum_220', 'F_8_log_return_amin_220', 'F_8_diff120', 'F_8_diff140', 'F_8_diff_220', 'F_10_log_return_std_220', 'F_11_log_return_sum_220', 'F_11_log_return_realized_volatility_220', 'F_11_diff_10', 'F_11_diff30', 'F_11_diff_50', 'F_11_diff220', 'F_12_log_return', 'F_12_log_return_sum_220', 'F_12_log_return_std_220', 'F_12_diff10', 'F_12_diff_120', 'F_12_diff140', 'F_12_diff220', 'F_13_log_return_sum_220', 'F_13_log_return_std_220', 'F_13_log_return_amax_220', 'F_13_diff5', 'F_13_diff_5', 'F_13_diff30', 'F_13_diff_50', 'F_13_diff120', 'F_13_diff180', 'F_13_diff_180', 'F_13_diff220']

NeroCube commented 3 years ago

Python Environment

virtualenv env
source env/bin/activate

Package Install

pip install -r requirements.txt

Run App

python app.py
NeroCube commented 3 years ago
def variance_selector(df, threshold=0.9):
    feature_cols = [ col for col in df.columns if col not in ["actual_date", "event_date", "y"]] 
    X = df[feature_cols]
    selector = VarianceThreshold(threshold).fit(X)
    return df[df.columns[selector.get_support(indices=True)]].columns