# Machine Learning Model to predict Bitcoin Price in Python

Today we’ll make a Machine Learning Model which will predict Bitcoin price in Python. This can be done in several numbers of ways. For example, we can use Linear regression, SVM or other ML algorithms.

For this, we will discuss Multiple linear regression models. We will use the dataset to train this model and will predict the Closing price of bitcoin.

## Dataset of Bitcoin price

Different datasets are available to solve our purpose. For this, we will be using a dataset from Kaggle.

You can download the Dataset BTC 1h.csv from this Link –https://www.kaggle.com/prasoonkottarathil/btcinusd#BTC%201h.csv

In this dataset, we will use four-column Open, High, Low and Close. We will give Open, High, Low as input and take Close as our output.

## Multiple Linear Regression Code to predict bitcoin price in Python

import pandas as pd from sklearn import linear_model data=pd.read_csv("/home/ashutosh/BITCOIN/BTC 1h.csv") # with sklearn X = data[['Open','High','Low']] # here we have 3 variables for multiple regression. Y = data['Close'] regr = linear_model.LinearRegression() regr.fit(X, Y) print('Intercept: \n', regr.intercept_) print('Coefficients: \n', regr.coef_) Open=int(input("Open:")) High=int(input("High:")) Low=int(input("Low:")) print ('Bitcoin Price', regr.predict([[Open,High,Low]]))

#### Output:

Intercept: 0.04707196065191965 Coefficients: [-0.40973491 0.76591559 0.64345592] Open: 6500 High: 6550 Low: 6450 Bitcoin Price [6503.80793861]

In this code, we first imported pandas and linear_model from sklearn for linear regression. Then imported our dataset using pandas from the desktop. After that, we will take X and Y values from the CSV extension file. And in last we fitted the model using *regr = linear_model.LinearRegression(). *

Also learn: Locally Weighted Linear Regression in Python

## Leave a Reply