SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Downloaden Sie, um offline zu lesen
6/6/23, 8:40 AM btc price predict
localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 1/5
Date Open High Low Close Adj Close Volume
0
2018-
01-06
17462.099609 17712.400391 16764.599609 17527.000000 17527.000000 18314600448
1
2018-
01-07
17527.300781 17579.599609 16087.700195 16477.599609 16477.599609 15866000384
2
2018-
01-08
16476.199219 16537.900391 14208.200195 15170.099609 15170.099609 18413899776
3
2018-
01-09
15123.700195 15497.500000 14424.000000 14595.400391 14595.400391 16659999744
4
2018-
01-10
14588.500000 14973.299805 13691.200195 14973.299805 14973.299805 18500800512
5
2018-
01-11
14968.200195 15018.799805 13105.900391 13405.799805 13405.799805 16534099968
6
2018-
01-12
13453.900391 14229.900391 13158.099609 13980.599609 13980.599609 12065699840
7
2018-
01-13
13952.400391 14659.500000 13952.400391 14360.200195 14360.200195 12763599872
8
2018-
01-14
14370.799805 14511.799805 13268.000000 13772.000000 13772.000000 11084099584
9
2018-
01-15
13767.299805 14445.500000 13641.700195 13819.799805 13819.799805 12750799872
Date
2018-01-06 17462.099609
2018-01-07 17527.300781
2018-01-08 16476.199219
2018-01-09 15123.700195
2018-01-10 14588.500000
Name: Open, dtype: float64
In [81]: import pandas as pd
import numpy as np
import datetime
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.model_selection import cross_val_score
import matplotlib.pylab as plt
%matplotlib inline
from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 15, 6
In [82]: df = pd.read_csv(r'C:UsersSunny MobilesDesktopBTC-USD.csv')
df.isnull().values.any()
df.head(10)
Out[82]:
In [83]: df['Date'] = pd.to_datetime(df['Date']).dt.date
group = df.groupby('Date')
Daily_Price = group['Open'].mean()
Daily_Price.head()
Out[83]:
In [84]: new_df= pd.DataFrame(list(Daily_Price), index = Daily_Price.index, columns = ["Clos
In [85]: new_df.head()
6/6/23, 8:40 AM btc price predict
localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 2/5
Close
Date
2018-01-06 17462.099609
2018-01-07 17527.300781
2018-01-08 16476.199219
2018-01-09 15123.700195
2018-01-10 14588.500000
Text(0, 0.5, '$(Dollar)')
Out[85]:
In [86]: plt.plot(new_df,color='green', lw=2)
plt.title("BitCoin Data",fontsize=24)
plt.xlabel('time in days',fontsize=24)
plt.ylabel('$(Dollar)',fontsize=24)
Out[86]:
In [87]: # df = df[['Close']]
df=new_df
forecast_out = int(20)
df['Prediction'] = df[['Close']].shift(-forecast_out)
X = np.array(df.drop(['Prediction'],1))
X = preprocessing.scale(X)
X_forecast = X[-forecast_out:]
X = X[:-forecast_out]
y = np.array(df['Prediction'])
y = y[:-forecast_out]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2,random_st
clf = LinearRegression()
clf.fit(X_train,y_train)
cross_validation = clf.predict(X_test)
confidence = clf.score(X_test, y_test)
print("confidence: ", confidence)
6/6/23, 8:40 AM btc price predict
localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 3/5
confidence: 0.91774107868374
[27372.83496361 26816.30660188 26876.41076526 27098.65757826
26741.90101745 26844.58046004 27201.44479188 26334.90230041
26474.99913149 26713.13935422 26859.29216765 28025.24373001
27705.33356037 27662.16459469 27195.45120228 26814.17954019
27228.27980971 27056.74027082 27103.19342056 25761.14757002]
C:UsersSunny MobilesAppDataLocalTempipykernel_118364198257280.py:7: FutureW
arning: In a future version of pandas all arguments of DataFrame.drop except for t
he argument 'labels' will be keyword-only.
X = np.array(df.drop(['Prediction'],1))
4542.036550091358
2023-06-06
forecast_prediction = clf.predict(X_forecast)
print(forecast_prediction)
In [88]: import matplotlib.pyplot as plt
# print(X_test)
# print(y_test)
# plt.plot(X_test,forecast_set,color='blue', linewidth=1)
plt.scatter(X_test, y_test, color='darkorange', label='test_data')
plt.plot(X_test, cross_validation, color='green', linewidth=2,label='predicted data
# plt.plot(new_df,color='green', lw=2)
plt.title("Crossvalidation (Linear Regression)",fontsize=24)
plt.xlabel('X_test',fontsize=24)
plt.ylabel('y',fontsize=24)
# plt.plot(X_test, forecast_prediction, color='blue', linew/idth=2)
plt.show()
In [89]: from sklearn.metrics import mean_squared_error
from math import sqrt
rms = sqrt(mean_squared_error(y_test, cross_validation))
print(rms)
In [90]: last_date = new_df.iloc[-1].name
print(last_date)
In [91]: import pandas as pd
import numpy as np
from datetime import datetime, timedelta
date_today = last_date
days = pd.date_range(date_today, date_today + timedelta(19), freq='D')
print(len(days),len(forecast_prediction))
df1 = pd.DataFrame({'Date': days, 'Close': forecast_prediction})
df1 =df1.set_index('Date')
6/6/23, 8:40 AM btc price predict
localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 4/5
20 20
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 20 entries, 2023-06-06 to 2023-06-25
Data columns (total 1 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Close 20 non-null float64
dtypes: float64(1)
memory usage: 320.0 bytes
Close Prediction
Date
2018-01-06 17462.099609 11256.000000
2018-01-07 17527.300781 11174.900391
2018-01-08 16476.199219 11475.299805
2018-01-09 15123.700195 11755.500000
2018-01-10 14588.500000 11306.799805
Text(0, 0.5, '$(Dollar)')
df1.info()
print(df.head())
In [92]: # # df['Close'].plot()
# df1['Close'].plot()
# plt.legend(loc=4)
# plt.xlabel('Date')
# plt.ylabel('Price')
# plt.show()
plt.plot(df1,color='green', lw=2)
plt.title("Predicted Next 30 Days",fontsize=24)
plt.xlabel('time in days',fontsize=24)
plt.ylabel('$(Dollar)',fontsize=24)
Out[92]:
In [93]: # plt.figure(figsize=(12,8))
# plt.plot(df['Close'], label='Train')
# plt.plot(df1['Close'], label='Predicted')
# # plt.plot(X_test['Close'], label='Test')
# # plt.plot(y_hat_avg['avg_forecast'], label='Average Forecast')
# plt.legend(loc='best')
# plt.show()
plt.plot(df1,)
plt.plot(df['Close'],color='green', lw=2, label='Bitcoin Data')
plt.plot(df1['Close'],color='red', lw=2, label='Predicted')
plt.title("Predicted (Linear Regression 30 Days)",fontsize=24)
6/6/23, 8:40 AM btc price predict
localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 5/5
Text(0, 0.5, '$(Dollar)')
plt.xlabel('time in days',fontsize=24)
plt.ylabel('$(Dollar)',fontsize=24)
Out[93]:

Weitere ähnliche Inhalte

Ähnlich wie Machine Learning final project (Bitcoin Price Prediction).pdf

Analisis gap dan thurstone
Analisis gap dan thurstoneAnalisis gap dan thurstone
Analisis gap dan thurstone
M Taufiq Budi H
 
Tablas Financieras de Factor Valor Actual y Valor Futuro Anualidades y Cantid...
Tablas Financieras de Factor Valor Actual y Valor Futuro Anualidades y Cantid...Tablas Financieras de Factor Valor Actual y Valor Futuro Anualidades y Cantid...
Tablas Financieras de Factor Valor Actual y Valor Futuro Anualidades y Cantid...
emperatrizazul
 
Scrypt Chacha by Travis Tolle (Ultracoin)
Scrypt Chacha by Travis Tolle (Ultracoin)Scrypt Chacha by Travis Tolle (Ultracoin)
Scrypt Chacha by Travis Tolle (Ultracoin)
Hashers United
 
Learning iPython Notebook Volatility Memory Forensics
Learning iPython Notebook Volatility Memory ForensicsLearning iPython Notebook Volatility Memory Forensics
Learning iPython Notebook Volatility Memory Forensics
Vincent Ohprecio
 
Matematica financeira regular 13
Matematica financeira regular 13Matematica financeira regular 13
Matematica financeira regular 13
J M
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your ApplicationUsing PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your Application
Steven Pousty
 
Demonstration using Jupyter R
Demonstration using Jupyter RDemonstration using Jupyter R
Demonstration using Jupyter R
宁 梅
 

Ähnlich wie Machine Learning final project (Bitcoin Price Prediction).pdf (20)

Trigonometric tables
Trigonometric tablesTrigonometric tables
Trigonometric tables
 
Trigonometric tables
Trigonometric tablesTrigonometric tables
Trigonometric tables
 
Sample Calculations for solar rooftop project in India
Sample Calculations for solar rooftop project in IndiaSample Calculations for solar rooftop project in India
Sample Calculations for solar rooftop project in India
 
Energy Analysis - Growth Rate 1984 - 2000 - 2019
Energy Analysis - Growth Rate 1984 - 2000 - 2019Energy Analysis - Growth Rate 1984 - 2000 - 2019
Energy Analysis - Growth Rate 1984 - 2000 - 2019
 
Machine Learning Model for M.S admissions
Machine Learning Model for M.S admissionsMachine Learning Model for M.S admissions
Machine Learning Model for M.S admissions
 
Analisis gap dan thurstone
Analisis gap dan thurstoneAnalisis gap dan thurstone
Analisis gap dan thurstone
 
Tablas Financieras de Factor Valor Actual y Valor Futuro Anualidades y Cantid...
Tablas Financieras de Factor Valor Actual y Valor Futuro Anualidades y Cantid...Tablas Financieras de Factor Valor Actual y Valor Futuro Anualidades y Cantid...
Tablas Financieras de Factor Valor Actual y Valor Futuro Anualidades y Cantid...
 
Fisher
FisherFisher
Fisher
 
Tablaf
TablafTablaf
Tablaf
 
Scrypt Chacha by Travis Tolle (Ultracoin)
Scrypt Chacha by Travis Tolle (Ultracoin)Scrypt Chacha by Travis Tolle (Ultracoin)
Scrypt Chacha by Travis Tolle (Ultracoin)
 
第7回 大規模データを用いたデータフレーム操作実習(1)
第7回 大規模データを用いたデータフレーム操作実習(1)第7回 大規模データを用いたデータフレーム操作実習(1)
第7回 大規模データを用いたデータフレーム操作実習(1)
 
Sales forecasting using sas
Sales forecasting using sasSales forecasting using sas
Sales forecasting using sas
 
Learning iPython Notebook Volatility Memory Forensics
Learning iPython Notebook Volatility Memory ForensicsLearning iPython Notebook Volatility Memory Forensics
Learning iPython Notebook Volatility Memory Forensics
 
Tokenization tracker 2018-10-30
Tokenization tracker 2018-10-30Tokenization tracker 2018-10-30
Tokenization tracker 2018-10-30
 
Analytics technology Introduction
Analytics technology IntroductionAnalytics technology Introduction
Analytics technology Introduction
 
Matematica financeira regular 13
Matematica financeira regular 13Matematica financeira regular 13
Matematica financeira regular 13
 
03.3 homogeneous debt portfolios
03.3   homogeneous debt portfolios03.3   homogeneous debt portfolios
03.3 homogeneous debt portfolios
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your ApplicationUsing PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your Application
 
Demonstration using Jupyter R
Demonstration using Jupyter RDemonstration using Jupyter R
Demonstration using Jupyter R
 
Spark Summit Dublin 2017 - MemSQL - Real-Time Image Recognition
Spark Summit Dublin 2017 - MemSQL - Real-Time Image RecognitionSpark Summit Dublin 2017 - MemSQL - Real-Time Image Recognition
Spark Summit Dublin 2017 - MemSQL - Real-Time Image Recognition
 

Kürzlich hochgeladen

notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Kürzlich hochgeladen (20)

notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 

Machine Learning final project (Bitcoin Price Prediction).pdf

  • 1. 6/6/23, 8:40 AM btc price predict localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 1/5 Date Open High Low Close Adj Close Volume 0 2018- 01-06 17462.099609 17712.400391 16764.599609 17527.000000 17527.000000 18314600448 1 2018- 01-07 17527.300781 17579.599609 16087.700195 16477.599609 16477.599609 15866000384 2 2018- 01-08 16476.199219 16537.900391 14208.200195 15170.099609 15170.099609 18413899776 3 2018- 01-09 15123.700195 15497.500000 14424.000000 14595.400391 14595.400391 16659999744 4 2018- 01-10 14588.500000 14973.299805 13691.200195 14973.299805 14973.299805 18500800512 5 2018- 01-11 14968.200195 15018.799805 13105.900391 13405.799805 13405.799805 16534099968 6 2018- 01-12 13453.900391 14229.900391 13158.099609 13980.599609 13980.599609 12065699840 7 2018- 01-13 13952.400391 14659.500000 13952.400391 14360.200195 14360.200195 12763599872 8 2018- 01-14 14370.799805 14511.799805 13268.000000 13772.000000 13772.000000 11084099584 9 2018- 01-15 13767.299805 14445.500000 13641.700195 13819.799805 13819.799805 12750799872 Date 2018-01-06 17462.099609 2018-01-07 17527.300781 2018-01-08 16476.199219 2018-01-09 15123.700195 2018-01-10 14588.500000 Name: Open, dtype: float64 In [81]: import pandas as pd import numpy as np import datetime from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split from sklearn.model_selection import cross_val_score import matplotlib.pylab as plt %matplotlib inline from matplotlib.pylab import rcParams rcParams['figure.figsize'] = 15, 6 In [82]: df = pd.read_csv(r'C:UsersSunny MobilesDesktopBTC-USD.csv') df.isnull().values.any() df.head(10) Out[82]: In [83]: df['Date'] = pd.to_datetime(df['Date']).dt.date group = df.groupby('Date') Daily_Price = group['Open'].mean() Daily_Price.head() Out[83]: In [84]: new_df= pd.DataFrame(list(Daily_Price), index = Daily_Price.index, columns = ["Clos In [85]: new_df.head()
  • 2. 6/6/23, 8:40 AM btc price predict localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 2/5 Close Date 2018-01-06 17462.099609 2018-01-07 17527.300781 2018-01-08 16476.199219 2018-01-09 15123.700195 2018-01-10 14588.500000 Text(0, 0.5, '$(Dollar)') Out[85]: In [86]: plt.plot(new_df,color='green', lw=2) plt.title("BitCoin Data",fontsize=24) plt.xlabel('time in days',fontsize=24) plt.ylabel('$(Dollar)',fontsize=24) Out[86]: In [87]: # df = df[['Close']] df=new_df forecast_out = int(20) df['Prediction'] = df[['Close']].shift(-forecast_out) X = np.array(df.drop(['Prediction'],1)) X = preprocessing.scale(X) X_forecast = X[-forecast_out:] X = X[:-forecast_out] y = np.array(df['Prediction']) y = y[:-forecast_out] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2,random_st clf = LinearRegression() clf.fit(X_train,y_train) cross_validation = clf.predict(X_test) confidence = clf.score(X_test, y_test) print("confidence: ", confidence)
  • 3. 6/6/23, 8:40 AM btc price predict localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 3/5 confidence: 0.91774107868374 [27372.83496361 26816.30660188 26876.41076526 27098.65757826 26741.90101745 26844.58046004 27201.44479188 26334.90230041 26474.99913149 26713.13935422 26859.29216765 28025.24373001 27705.33356037 27662.16459469 27195.45120228 26814.17954019 27228.27980971 27056.74027082 27103.19342056 25761.14757002] C:UsersSunny MobilesAppDataLocalTempipykernel_118364198257280.py:7: FutureW arning: In a future version of pandas all arguments of DataFrame.drop except for t he argument 'labels' will be keyword-only. X = np.array(df.drop(['Prediction'],1)) 4542.036550091358 2023-06-06 forecast_prediction = clf.predict(X_forecast) print(forecast_prediction) In [88]: import matplotlib.pyplot as plt # print(X_test) # print(y_test) # plt.plot(X_test,forecast_set,color='blue', linewidth=1) plt.scatter(X_test, y_test, color='darkorange', label='test_data') plt.plot(X_test, cross_validation, color='green', linewidth=2,label='predicted data # plt.plot(new_df,color='green', lw=2) plt.title("Crossvalidation (Linear Regression)",fontsize=24) plt.xlabel('X_test',fontsize=24) plt.ylabel('y',fontsize=24) # plt.plot(X_test, forecast_prediction, color='blue', linew/idth=2) plt.show() In [89]: from sklearn.metrics import mean_squared_error from math import sqrt rms = sqrt(mean_squared_error(y_test, cross_validation)) print(rms) In [90]: last_date = new_df.iloc[-1].name print(last_date) In [91]: import pandas as pd import numpy as np from datetime import datetime, timedelta date_today = last_date days = pd.date_range(date_today, date_today + timedelta(19), freq='D') print(len(days),len(forecast_prediction)) df1 = pd.DataFrame({'Date': days, 'Close': forecast_prediction}) df1 =df1.set_index('Date')
  • 4. 6/6/23, 8:40 AM btc price predict localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 4/5 20 20 <class 'pandas.core.frame.DataFrame'> DatetimeIndex: 20 entries, 2023-06-06 to 2023-06-25 Data columns (total 1 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Close 20 non-null float64 dtypes: float64(1) memory usage: 320.0 bytes Close Prediction Date 2018-01-06 17462.099609 11256.000000 2018-01-07 17527.300781 11174.900391 2018-01-08 16476.199219 11475.299805 2018-01-09 15123.700195 11755.500000 2018-01-10 14588.500000 11306.799805 Text(0, 0.5, '$(Dollar)') df1.info() print(df.head()) In [92]: # # df['Close'].plot() # df1['Close'].plot() # plt.legend(loc=4) # plt.xlabel('Date') # plt.ylabel('Price') # plt.show() plt.plot(df1,color='green', lw=2) plt.title("Predicted Next 30 Days",fontsize=24) plt.xlabel('time in days',fontsize=24) plt.ylabel('$(Dollar)',fontsize=24) Out[92]: In [93]: # plt.figure(figsize=(12,8)) # plt.plot(df['Close'], label='Train') # plt.plot(df1['Close'], label='Predicted') # # plt.plot(X_test['Close'], label='Test') # # plt.plot(y_hat_avg['avg_forecast'], label='Average Forecast') # plt.legend(loc='best') # plt.show() plt.plot(df1,) plt.plot(df['Close'],color='green', lw=2, label='Bitcoin Data') plt.plot(df1['Close'],color='red', lw=2, label='Predicted') plt.title("Predicted (Linear Regression 30 Days)",fontsize=24)
  • 5. 6/6/23, 8:40 AM btc price predict localhost:8889/nbconvert/html/Bitcoin price prediction/btc price predict.ipynb?download=false 5/5 Text(0, 0.5, '$(Dollar)') plt.xlabel('time in days',fontsize=24) plt.ylabel('$(Dollar)',fontsize=24) Out[93]: