Merge pull request #182 from DidierRLopes/fix-knn-regression

Fix knn regression
This commit is contained in:
DidierRLopes
2021-03-15 20:59:30 +00:00
committed by GitHub
2 changed files with 3 additions and 1 deletions

View File

@@ -145,9 +145,9 @@ def k_nearest_neighbors(l_args, s_ticker, df_stock):
# Plotting
plt.figure()
plt.plot(df_stock.index, df_stock["5. adjusted close"], lw=2)
s_knn = f"{ns_parser.n_neighbors}-Nearest Neighbors on {s_ticker}"
# BACKTESTING
if ns_parser.s_end_date:
s_knn = f"{ns_parser.n_neighbors}-Nearest Neighbors on {s_ticker}"
plt.title(f"BACKTESTING: {s_knn} - {ns_parser.n_days} days prediction")
else:
plt.title(f"{s_knn} - {ns_parser.n_days} days prediction")

View File

@@ -343,6 +343,8 @@ def regression(l_args, s_ticker, df_stock, polynomial):
print_pretty_prediction(df_pred, df_stock["5. adjusted close"].values[-1])
print("")
except SystemExit:
print("")
except Exception as e:
print(e)
print("")