jieyima / cryptocurrency_investment_analysis_and_modeling Goto Github PK
View Code? Open in Web Editor NEWMachine learning regression algorithm on cryptocurrency stock price for the next 30 days.
Machine learning regression algorithm on cryptocurrency stock price for the next 30 days.
accumulate_by <- function(dat, var) {
var <- lazyeval::f_eval(var, dat)
lvls <- plotly:::getLevels(var)
dats <- lapply(seq_along(lvls), function(x) {
cbind(dat[var %in% lvls[seq(1, x)], ], frame = lvls[[x]])
})
dplyr::bind_rows(dats)
}
d <- txhousing %>%
filter(year > 2005, city %in% c("Abilene", "Bay Area")) %>%
accumulate_by(~date)
If you implement a cumulative animation in the manner of the function above, the number of rows will increase too much.
I use a thousand frames and a row of ten thousand. Because of the large number of data, the work in progress has been disturbed.
https://plot.ly/r/cumulative-animations/
Is there any way to create a cumulative animation other than the example?
I used your project as a draft for an assignment and made some edits. This arrangement is that I'm estimating BTC with 2 different algorithms, but as you can see, the results of 2 different algorithms are the same. Does anyone know what you think I am doing wrong. Thanks for helping me @jieyima
https://ibb.co/HHHMkH7 and https://ibb.co/GPBymjr Photos
def regression1(X_train, X_test, y_train, y_test):
Regressor = {'Random Forest Regressor': RandomForestRegressor(n_estimators=200)}
for name, clf in Regressor.items():
print(name)
clf.fit(X_train, y_train)
st = time.time()
print(f'R-Squared: {r2_score(y_test, clf.predict(X_test)):.9f}')
et = time.time()
print(f'Mean absolute error: {mean_absolute_error(y_test, clf.predict(X_test)):.9f}')
print(f'Mean squared error: {mean_squared_error(y_test, clf.predict(X_test)):.9f}')
print('Execution time:', et - st)
print()
# define regression function
def regression2(X_train, X_test, y_train, y_test):
Regressor = {'Extreme Gradient Boosting Regressor': GradientBoostingRegressor(n_estimators=500)}
for name, clf in Regressor.items():
print(name)
clf.fit(X_train, y_train)
st = time.time()
print(f'R-Squared: {r2_score(y_test, clf.predict(X_test)):.9f}')
et = time.time()
print(f'Mean absolute error: {mean_absolute_error(y_test, clf.predict(X_test)):.9f}')
print(f'Mean squared error: {mean_squared_error(y_test, clf.predict(X_test)):.9f}')
print('Execution time:', et - st)
print()
# Bitcoin (BTC)
print('Bitcoin (BTC):')
regression1(X_train_BTC, X_test_BTC, y_train_BTC, y_test_BTC)
plt.figure(figsize=(15,8))
(bitcoin[:0]['daily_avg']).plot(label='Historical Price')
(bitcoin[-31:]['daily_avg']).plot(label='Predicted Price')
plt.xlabel('Time')
plt.ylabel('Price in USD')
plt.title('Prediction with Random Forest Regressor')
# Bitcoin (BTC)
print('Bitcoin (BTC):')
regression2(X_train_BTC, X_test_BTC, y_train_BTC, y_test_BTC)
plt.figure(figsize=(15,8))
(bitcoin[:0]['daily_avg']).plot(label='Historical Price')
(bitcoin[-31:]['daily_avg']).plot(label='Predicted Price')
plt.xlabel('Time')
plt.ylabel('Price in USD')
plt.title('Prediction with Extreme Gradient Boosting Regressor')```
If you have problems with installation, let me know.
I am searching collaborators for this project. If you have experience and want to collaborate text me on email or github Issues
Things this project offers that I did not find in other free projects, are:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.