GithubHelp home page GithubHelp logo

pawlodkowski / bitcoin-prediction Goto Github PK

View Code? Open in Web Editor NEW
5.0 0.0 3.0 912 KB

Python tutorial for predicting the price of BTC using regression models.

License: MIT License

Jupyter Notebook 100.00%

bitcoin-prediction's Introduction

Overview


This repository contains 2 iPython (Jupyter) notebook files:

  1. The primary file, BitcoinPricePrediction.ipynb, which serves as a tutorial for predicting the price of Bitcoin (2 days in the future) based on data pulled from the CoinGecko API.
  2. A secondary file, MakingPredictionsWithModel-Demo.ipynb, which further breaks down Step 5 of the primary file (i.e. the code that is used to generate the DataFrame used as the "test data set" for making the actual prediction).

Task:


The task is to train a linear regression model to predict what the price of Bitcoin will in 1-2 days. The features used in the model are mostly historical prices of Bitcoin and other cryptocurrencies (e.g. BTC price from 2 days ago, ETH price from 2 days ago) as well as "community data" (e.g. social media-related statistics) that can be extracted from the CoinGecko API.

This notebook includes examples of various data analysis, modeling, and visualization techniques that can be used to solve the problem using Python. The purpose of this file is not to predict the most accurate price of Bitcoin in the future (cryptocurrency prices are inherently volatile / wildly unpredictable) nor to thoroughly teach financial time series analysis and statistics, but rather to be used as a guide for teaching students introductory data analysis and web-scraping tools in Python. These tools and strategies include:

  • "Wrangling" data in pandas and applying features engineering to a data set.
  • Visualzing data in matplotlib and seaborn to inform optimal feature selection.
  • Training 3 types of classification models (Linear Regression, Ridge Regression, Lasso Regression) on the data set and using them to make predictions.
    • In the preceding lectures, the students will get a more in-depth, theoretical understanding of how regularization works, why it is used, and how it affects the resulting model's coefficients.
  • Using requests in Python to learn how to extract your own data from the internet; in this case, a relatively simple API that outputs clean data in JSON format and does not require any authentication.

TO-DO:

A more rigorous analysis of the financial time series data can be explored with the statsmodels library in Python. Models to be added in a future notebook:

  • Exponential Smoothing
  • Autoregressive-moving-average (ARMA).

bitcoin-prediction's People

Contributors

pawlodkowski avatar

Stargazers

 avatar Keyne avatar  avatar Giant Elk avatar  avatar

bitcoin-prediction's Issues

Create function that applies all selected featured engineering changes to any DataFrame used for the model.

JSONDecodeError Traceback (most recent call last)
Input In [71], in
125 #just to be safe
127 return a
--> 129 training_data = apply_changes(merged_df)
130 training_data.head()
Input In [71], in apply_changes(dataframe)
59 a.dropna(inplace=True)
60 # print(a)
---> 62 a = get_btc_community_data(a,
63 'reddit_average_posts_48h',
64 'reddit_average_comments_48h',
65 'facebook_likes',
66 'twitter_followers')
67 print(a)
68 a = a.interpolate(method='linear')
Input In [71], in get_btc_community_data(dataframe, feat1, feat2, feat3, feat4)
16 url2 = url2_pre + date
17 info = requests.get(url2)
---> 18 j1 = info.json()
19 time = pd.to_datetime(date)
21 f1 = j1['community_data'][feat1]
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I am getting this error could you pls resolve it

Problem when run

I'm trying to run BitcoinPricePrediction.ipynb in Google Colab and I got this error:

ValueError                                Traceback (most recent call last)
<ipython-input-7-762086e1f01e> in <module>()
    123     return a
    124 
--> 125 training_data = apply_changes(merged_df)
    126 training_data.head()

3 frames
/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
    584                              " minimum of %d is required%s."
    585                              % (n_samples, array.shape, ensure_min_samples,
--> 586                                 context))
    587 
    588     if ensure_min_features > 0 and array.ndim == 2:

ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required by MinMaxScaler.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.