Price Prediction of Bitcoin Documentation
Price Prediction of Bitcoin Documentation
In
By
Loyola Academy
Old Alwal,Secunderabad,500010
2021-2022
A PROJECT REPORT ON
In
By
Loyola Academy
Old Alwal,Secunderabad,500010
2021-2022
Loyola Academy
Old Alwal,Secunderabad,500010
CERTIFICATE
This is to certify that the project entitled Arduino based Hand Gesture Control of computer
is a record of bonafide work carried out during III year 5 st semester as partial fulfillment for the
award of the DEGREE OF BACHELOR OF SCIENCES IN COMPUTER SCIENCE AND
ENGINEERING During the academic year 2021-22.
The results embodied in this project report have not been submitted to any other University or
Institute for the award of any Degree or Diploma
CLASS : DCS
DECLARATION
We hereby declare that the project entitled “Arduino based Hand Gesture
Control of computer” done by NEKNATH UDAY KUMAR
(111719013053) and LEE THOMAS (111719013044) submitted a record of an
original work done by us.
The project has been successfully completed and submitted in partial fulfillment of
the requirements for the award of “DEGREE OF BACHELOR OF SCIENCE
IN COMPUTER SCIENCE AND ENGINEERING” from “LOYOLA
ACADEMY” affiliated to “Osmania University, Hyderabad” in the authentic
way and has not been submitted in any other university or institution for the award
of any degree or diploma.
ACKNOWLEDGEMENT
“Task successful” makes everyone happy. But the happiness wills gold without glitter if we didn’t
state the persons who have supported us to make a success.
Success will be crowned to people who made it reality but people who constant
guidance and encouragement made it possible crowned first on the eve of success.
I would like to express our thankfulness to our project guide MRS.K.ANITHA, Head
of the Department for her constant motivation and valuable help through the project
work, and we express our gratitude for her supervision, guidance and cooperation
through the project.
ABSTRACT
The main goal of the paper is to use Arduino and Ultrasonic sensors, as
well as various Python packages, to enhance the precision and speed of the
computer interface.
Keywords–
Hand gesture,
IoT,
Ultrasonic sensors,
Arduino-uno,
Python,
Gesture control
CONTENTS PG.NO
S.NO
Abstract
1. Introduction
2. System Specifications
2.1. Software requirements
2.2. Hardware requirements
3. System Analysis
3.1. Existing System
3.2. Proposed System
3.3. Feasibility Study
3.4. Modules
4. System Design
4.1. Input Design
4.2. Output Design
4.3. System Architecture
4.4. UML Diagram
6. Output Screens
7. Conclusion
8. Future Enhancement
9. References
10. Appendix-A
11. Appendix-B
1. INTRODUCTION
SYSTEM SPECIFICATIONS
SOFTWARE REQUIREMENTS:
general overview of the project in regards to what the areas of strength and
Arduino UNO x 1
Ultrasonic Sensors x 2
USB Cable (for Arduino)
Few Connecting Wires
A Laptop with internet connection
HARDWARE REQUIREMENTS:
The gesture control is based on specifying the hand moments from the ultrasonic sensor.
This project is implemented using various components. We need to deploy ultrasonic
sensors which are connected to Arduino, then place yor hand in-front of the Ultrasonic
sensor which will calculate the distance between the hand and the sensor. Using this
following information, particular task or operation will be executed
1. ULTRASONIC SENSORS
The following figure will explain the steps to perform the operations in the
system by using hand gestures. The hand or any item should first be positioned
in front of the sensors, after which the sensors will emit sound waves, which
will travel through the air and be reflected as echo waves when they strike our
hand or any item, that is received by echo hole.
ARDUINO BOARD
LAPTOP/PC
In the real world, the ultrasonic sensors are used for interacting with robots,
computers and other devices. This sensor senses the proximity and detects
levels with high
The Arduino is an open- source electronic platform which is used to build the
hardware (microcontroller, a small computer) and software projects. Arduino board
consists of both hardware part and also software part (IDE). Arduino board is used
for controlling certain defined functions. Arduino board is powered by using a USB
Cable from computer, etc.
Arduino Board has 14 input/output pins. Language used for programming the
Arduino board could be C/C++. Arduino board also consists of Reset Button, that
temporarily connects the reset pin to the ground and restart the code that is loaded
on Arduino Board. Power LED Indicator is also integrated on the Arduino board.
This LED will turn on whenever we plug the Arduino into a power source. TX and
RX LEDs are used during serial communication. TX and RX Pin are used for
transmitting and receiving of data. The main IC on the board belongs to the AT
Mega family, 328 AT Mega IC.
4. Circuit Connection
The circuit diagram of Arduino and the setup is quite simple. The trigger and echo
pins of the first ultrasonic sensor are connected to two pins of Arduino board. For
second ultrasonic sensor, the trigger pin and echo pin are also connected to two
different pins. The Ultrasonic calculate the distance between the hand moments and
the sensor and using the following information, the laptop/computer performs the
task/operations. The information of distance from Arduino is collected by Python
program. PyAutoGUI, a special library converts the data into keyboard click
actions.
6. Jumper Wires
Jumper wires are simple cables having connector pins on both ends that may be used to
connect two points without the use of solder. Jumper wires are commonly used with
breadboards and other prototyping tools to allow for quick circuit changes. It's quite
straightforward, Jumper wires are the most fundamental of all electrical components.
SYSTEM ANALYSIS
EXISTING SYSTEM
While using colour bands users use red, blue and green bands and put them to their
fingers. So, while using this technique kinect sensor projects an infrared pattern of
307,200 dots in a 640 × 480 mesh and receives reflected pattern CMOS monochrome
sensor. This structured light application permits the machine to estimate the intensity
of every point using triangulation. Moreover, an RGB camera provides synchronised
colour information for each point.
Using web camera technology, we need a projector which projects the display on
a clear wall or any other plain surface. User can interact with the projected screen using
his fingertips which are tracked in the air by the camera using camshaft tracker. A
related study of distinct methods of hand gesture detection has been made. Here an
efficient technique is employed to identify the hand gestures which are transformed into
relevant actions.
When we are working with IR sensors the user is equipped with a glove which was
fitted with IR sensors that acts as a bridge between user and computer. The gloves are
used to recognize the hand gestures of the disabled people and convert those gestures into
meaningful messages in real time. With the amount of bend made by the fingers
continuous data stream is obtained as output from Infrared (IR) sensor. IR sensors change
the output voltage depending on the strength of the received signal. Change in bend is
converted to change in the electrical voltage by IR sensors. The output from IR sensors is
processed by a microcontroller and a corresponding message is displayed.
Controlling the computer with hand gestures using projectors is only used for
gamming applications and this will not sense the objects exactly when the lighting
was changed.
When controlling the computer with hand gestures using web cameras, it is
difficult to interact with system using camshaft in the air and this is time taken
thing to project on the plain surface and as it needs extra plain surface along with
the requirements of the project to project, we
While controlling the system with hand gestures using IR sensors, it is difficult to
always bend the fingers and is expensive to buy IR sensors and also these sensors
will not work in lighting.
So, we demonstrate the easy and cost-effective gesture controlling of computer by
using ultrasonic sensors instead of using IR sensors, color bands, web cameras,
projectors. As ultrasonic sensors are portable to move, cost effective and easy to
operate we implemented the project by using ultrasonic sensors. Hence it is easily
affordable by anyone and also easy to operate with the hand just by waving in front
of the sensors.
PROPOSED METHOD
The time it takes to emit and receive sound waves is recorded here, and the
distance is determined using that information. The activities in the system will be
done based on the distance. The hand gesture computers will function in this
manner.
FEASIBILITY STUDY
The feasibility of the project is analyzed in this phase and a business proposal is
put forth with a very general plan for the project and some cost estimates. During
system analysis the feasibility study of the proposed system is to be carried out.
This is to ensure that the proposed system is not a burden to the company. For
feasibility analysis, some understanding of the major requirements for the system is
essential.
¨ ECONOMICAL FEASIBILITY
¨ TECHNICAL FEASIBILITY
¨ SOCIAL FEASIBILITY
ECONOMICAL FEASIBILITY
This study is carried out to check the economic impact that the system will have on
the organization. The amount of funds that the company can pour into the research
and development of the system is limited. The expenditures must be justified. Thus
the developed system as well within the budget and this was achieved because most
of the technologies used are freely available. Only the customized products had to
be purchased.
B.Sc. COMPUTER SCIENCE AND ENGINEERING
6
PRICE PREDICTION OF BITCOIN 2021-2022
TECHNICAL FEASIBILITY
This study is carried out to check the technical feasibility, that is, the technical requirements of
the system. Any system developed must not have a high demand on the available technical
resources. This will lead to high demands on the available technical resources. This will lead to
high demands being placed on the client. The developed system must have a modest
requirement, as only minimal or null changes are required for implementing this system.
SOCIAL FEASIBILITY
The aspect of study is to check the level of acceptance of the system by the user. This includes
the process of training the user to use the system efficiently. The user must not feel threatened
by the system, instead must accept it as a necessity. The level of acceptance by the users solely
depends on the methods that are employed to educate the user about the system and to make
him familiar with it. His level of confidence must be raised so that he is also able to make some
constructive criticism, which is welcomed, as he is the final user of the system
MODULES
1. TENSORFLOW:
TensorFlow is a free and open-source software library for dataflow and differentiable
programming across a range of tasks. It is a symbolic math library, and is also used for
machine learning applications such as neural networks. It is used for both research and
production at Google.
TensorFlow was developed by the Google Brain team for internal Google use. It was
released under the Apache 2.0 open-source license on November 9, 2015.
Numpy
It is the fundamental package for scientific computing with Python. It contains various features including these
important ones:
SYSTEM DESIGN
INPUT DESIGN:
considering the requirements, procedures to collect the necessary input data in most
efficiently designed. The input design has been done keeping in view that, the
interaction of the user with the system being the most effective and simplified way.
OUTPUT DESIGN:
All the screens of the system are designed with a view to provide the user with easy operations
in simpler and efficient way, minimum key strokes possible. Instructions and important
information is emphasized on the screen. Almost every screen is provided with no error and
important messages and option selection facilitates. Emphasis is given for speedy processing and
speedy transaction between the screens. Each screen assigned to make it as much user friendly as
possible by using interactive procedures. So to say user can operate the system without much
help from the operating manual.
SYSTEM ARCHITECTURE:
1. The DFD is also called as bubble chart. It is a simple graphical formalism that can be used to
represent a system in terms of input data to the system, various processing carried out on this data,
and the output data is generated by this system.
2. The data flow diagram (DFD) is one of the most important modeling tools. It is used to model
the system components. These components are the system process, the data used by the process, an
external entity that interacts with the system and the information flows in the system.
UML DIAGRAMS
The goal is for UML to become a common language for creating models of object oriented
computer software. In its current form UML is comprised of two major components: a Meta-model
and a notation. In the future, some form of method or process may also be added to; or associated
with, UML.
The UML represents a collection of best engineering practices that have proven successful in
the modeling of large and complex systems.
The UML is a very important part of developing objects oriented software and the software
development process. The UML uses mostly graphical notations to express the design of software
projects.
2. CLASS DIAGRAM:
The class diagram is used to refine the use case diagram and define a detailed design of the
system. The class diagram classifies the actors defined in the use case diagram into a set of
interrelated classes. The relationship or association between the classes can be either an "is-a"
or "has-a" relationship. Each class in the class diagram may be capable of providing certain
functionalities. These functionalities provided by the class are termed "methods" of the class.
Apart from this, each class may have certain "attributes" that uniquely identify the class.
3. SEQUENCE DIAGRAM:
A sequence diagram represents the interaction between different objects in the system. The
important aspect of a sequence diagram is that it is time-ordered. This means that the exact
sequence of the interactions between the objects is represented step by step. Different objects
in the sequence diagram interact with each other by passing "messages".
4. ACTIVITY DIAGRAM:
The process flows in the system are captured in the activity diagram. Similar to a state
diagram, an activity diagram also consists of activities, actions, transitions, initial and final
states, and guard conditions.
5. COLLABORATION DIAGRAM:
A collaboration diagram groups together the interactions between different objects. The
interactions are listed as numbered interactions that help to trace the sequence of the
interactions. The collaboration diagram helps to identify all the possible interactions that each
object has with other objects.
6. DEPLOYMENT DIAGRAM:
The deployment diagram captures the configuration of the runtime elements of the
application. This diagram is by far most useful when a system is built and ready to be
deployed.
7. COMPONENT DIAGRAM:
The component diagram represents the high-level parts that make up the system. This diagram
depicts, at a high level, what components form part of the system and how they are
interrelated. A component diagram depicts the components culled after the system has
undergone the development or construction phase.
The purpose of testing is to discover errors. Testing is the process of trying to discover every
conceivable fault or weakness in a work product. It provides a way to check the functionality of
components, sub assemblies, assemblies and/or a finished product . It is the process of exercising
software with the intent of ensuring that the Software system meets its requirements and user
expectations and does not fail in an unacceptable manner. There are various types of test. Each
test type addresses a specific testing requirement.
Unit testing, a testing technique using which individual modules are tested to determine if there
are issues by the developer himself.. it is concerned with functional correctness of the standalone
modules. The main aim is to isolate each unit of the system to identify, analyze and fix the
defects.
Black Box Testing - Using which the user interface, input and output are tested.
White Box Testing –Used to test each one of those functions behavior is tested.
Data flow testing is a family of testing strategies based on selecting paths through the program’s
control flow in order to explore the sequence of events related to the status of Variables or data
object. Data Flow Testing focuses on the points at which variables receive and the points at
which these values are used.
Integration Testing done upon completion of unit testing, the units or modules are to be
integrated which gives raise too integration testing. The purpose of integration testing is to verify
the functional, performance, and reliability between the modules that are integrated.
Big Bang Integration Testing is an integration testing Strategy wherein all units are linked at
once, resulting in a complete system. When this type of testing strategy is adopted, it is difficult
to isolate any errors found, because attention is not paid to verifying the interfaces across
individual units.
User interface testing, a testing technique used to identify the presence of defects is a
product/software under test by Graphical User interface [GUI].
IF NOT
S.NO INPUT IF AVAILABLE AVAILABLE
1
Load Bitcoin Data load data from Blockchain There is no process
from Blockchain
Algorithm
4
Run SVM We can see original Bitcoin There is no process
prices and then we can see
algorithm
Bitcoin predicted
6. OUTPUT SCREENS:
Python a versatile programming language doesn’t come pre-installed on your computer devices.
Python was first released in the year 1991 and until today it is a very popular high-level
programming language. Its style philosophy emphasizes code readability with its notable use of
great whitespace.
The object-oriented approach and language construct provided by Python enables programmers to
write both clear and logical code for projects. This software does not come pre-packaged with
Windows.
There have been several updates in the Python version over the years. It might be confusing for the
beginner who is willing to start learning Python but this tutorial will solve your query. The latest or
the newest version of Python is version 3.7.4 or in other words, it is Python 3.
Note: The python version 3.7.4 cannot be used on Windows XP or earlier devices.
Before you start with the installation process of Python. First, you need to know about your System
Requirements. Based on your system type i.e. operating system and based processor, you must
download the python version. My system type is a Windows 64-bit operating system. So the steps
below are to install python version 3.7.4 on Windows 7 device or to install Python 3. Download the
Python Cheatsheet here. The steps on how to install Python on Windows 10, 8 and 7 are divided
into 4 parts to help understand better.
Download the Correct version into the system
Step 1: Go to the official site to download and install python using Google Chrome or any other
web browser. OR Click on the following link: https://www.python.org
Now, check for the latest and the correct version for your operating system.
Step 3: You can either select the Download Python for windows 3.7.4 button in Yellow Color or
you can scroll further down and click on download with respective to their version. Here, we are
downloading the most recent python version for windows 3.7.4
Step 4: Scroll down the page until you find the Files option.
Step 5: Here you see a different version of python along with the operating system.
• To download Windows 32-bit python, you can select any one from the three options: Windows
x86 embeddable zip file, Windows x86 executable installer or Windows x86 web-based installer.
•To download Windows 64-bit python, you can select any one from the three options: Windows
x86-64 embeddable zip file, Windows x86-64 executable installer or Windows x86-64 web-based
installer.
Here we will install Windows x86-64 web-based installer. Here your first part regarding which
version of python is to be downloaded is completed. Now we move ahead with the second part in
installing python i.e. Installation
Note: To know the changes or updates that are made in the version you can click on the Release
Note Option.
INSTALLATION OF PYTHON
Step 1: Go to Download and Open the downloaded python version to carry out the installation
process.
Step 2: Before you click on Install Now, Make sure to put a tick on Add Python 3.7 to PATH.
Step 3: Click on Install NOW After the installation is successful. Click on Close.
With these above three steps on python installation, you have successfully and correctly installed
Python. Now is the time to verify the installation.
Step 3: Click on IDLE (Python 3.7 64-bit) and launch the program
Step 4: To go ahead with working in IDLE you must first save the file. Click on File > Click on
Save
Step 5: Name the file and save as type should be Python files. Click on SAVE. Here I have named
the files as Hey World.
SCREENSHOTS
In above screen click on ‘Load Bitcoin Data from Blockchain’ button to load data from Blockchain
and get below output
In above screen dataset loaded from Blockchain and now click on ‘Preprocess Dataset’ button to
preprocess dataset such as replacing missing values with 0 and then find total attributes before apply
SPCE
In above screen dataset is normalized and then we can see dataset contains total 476 records and
before applying SPCE dataset contains 6 attributes. Now click on ‘Run Subspace Learning SPCE
Algorithm’ button to apply SPCE algorithm to reduce high dimension 6 attributes to low dimension
and then will get below output
In above screen after applying SPCE attributes/features size is reduced to 4 from 6 and we can see
application using 380 records for training and 96 records for testing. Now dataset is ready and now
click on ‘Run SVM Algorithm’ button to train SVM and get below output
In above screen we can see original Bitcoin prices and then we can see Bitcoin predicted prices and
below graph showing difference between original and predicted prices
In above graph x-axis represents DAYS/DATE and y-axis represents Bitcoin prices and red line
represents original prices and green line represents predicted prices. In above graph we can see there
is huge difference between predicted and original prices so we can say SVM is not accurate and now
close above graph and then click on ‘Run Logistic Regression Algorithm’ button to train LR and get
below output
In above screen we can see logistic prediction prices and original prices and below is the LR graph
of price prediction
In above graph we can see LR is giving accurate price prediction as both lines are fully overlap and
we can see there less difference between both lines so LR is accurate and now click on ‘Run
ARIMA Algorithm’ button to train ARIMA and get below output
In above screen we can see original and ARIMA predicted prices and below is the ARIMA
prediction graph
In above ARIMA graph light blue line is the training prices and dark blue line is the test data and
yellow line is the predicted data and both test and predicted data is shadowed so we can say ARIMA
prediction is also accurate.
In this project we have evaluated the performance of SVM, Logistic Regression and ARIMA and in
all algorithm Logistic Regression and ARIMA is giving better prediction prices.
7. CONCLUSION:
After establishing the learning framework and completing the normalization, we intend to use
the methods mentioned above and choose the best method to solve the Bitcoin prediction
problem. In above ARIMA graph light blue line is the training prices and dark blue line is
the test data and yellow line is the predicted data and both test and predicted data is shadowed
so we can say ARIMA prediction is also accurate. In this project we have evaluated the
performance of SVM, Logistic Regression and ARIMA and in all algorithm Logistic
Regression and ARIMA is giving better prediction prices.
8.FUTURE ENHANCEMENT:
9. REFERENCES:
10. APPENDIX-A:
Python
Python features a dynamic type system and automatic memory management. It supports multiple
programming paradigms, including object-oriented, imperative, functional and procedural, and
has a large and comprehensive standard library.
Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to
compile your program before executing it. This is similar to PERL and PHP.
Python is Interactive − you can actually sit at a Python prompt and interact with the interpreter
directly to write your programs.
Python also acknowledges that speed of development is important. Readable and terse code is
part of this, and so is access to powerful constructs that avoid tedious repetition of code.
Maintainability also ties into this may be an all but useless metric, but it does say something
about how much code you have to scan, read and/or understand to troubleshoot problems or
tweak behaviors. This speed of development, the ease with which a programmer of other
languages can pick up basic Python skills and the huge standard library is key to another area
where Python excels. All its tools have been quick to implement, saved a lot of time, and several
of them have later been patched and updated by people with no Python background - without
breaking
IMPLEMENTATION:
In this project we are using Subspace Learning Algorithm called Supervised Principal Coefficients
Embedding (SPCE) to reduce high dimension data into low dimension. In machine learning all
algorithms get trained on past datasets and this dataset often contains irrelevant (unimportant)
features and this features will be removed by applying SPCE algorithm. SPCE algorithm will find
coefficients or fitness or each attribute by calculating accuracy and whatever features gave high
accuracy will be selected and remaining attributes will be remove out.
In this project we are using Blockchain technology to store BITCOIN historic price data. This data
will be retrieved by machine learning algorithms such as Logistic Regression, Support Vector
Machine and ARIMA. This algorithms will get trained on this data and then predict future price of
Bitcoin.
In all algorithms Logistic Regression is giving accurate prediction prices. To calculate performance
of each algorithm we have divided dataset into train and test where application used 80% dataset for
training and 20% dataset for testing. After training model we will apply test data on trained model to
predict prices and this prices will be check with original prices and if there is not much difference
between original and predicted prices then algorithm will be consider as accurate.
All Bitcoin data will be saved inside BlockchainEthereum tool and to store this data in
BlockchainEthereum we have designed SOLIDITY code which will allow us to read Bitcoin historic
data.
In above screen we will call SetData function to store Bitcoin prices in Blockchain and will call
GetData function to read data back.
Below is the Bitcoin dataset used in this project
In above dataset we have Bitcoin open and close prices with dates and this data will be stored in
Blockchain and then read back and trained by machine learning algorithms to predict future prices.
In below screen we are showing concept to deploy SOLIDITY code on Blockchain and this
SOLIDITY can be called from Python program to store and read data.
First go inside ‘hello-eth/node_modules/.bin’ folder and then look for file called ‘runBlockchain.bat’
and then double click on that file to start Ethereum tool like below screen.
In above screen private keys are generated and in same window type ‘truffle migrate’ command
and press enter key to deploy Bitcoin SOLIDITY contract in Blockchain and will get below output
In above screen we can see Bitcoin contract deployed and we can see its contract address and this
address we will specify in python program to access data from that Blockchain Solidity code and
now let above Blockchain console running. In below screen you can see that contract calling code in
python
In above screen read red colour comments to know about Blockchain Bitcoin contract calling.
BLOCKCHAIN TECHNOLOGY:
This means if one block in one chain was changed, it would be immediately apparent it had been
tampered with. If hackers wanted to corrupt a blockchain system, they would have to change every
block in the chain, across all of the distributed versions of the chain. Blockchains such as Bitcoin
and Ethereum are constantly and continually growing as blocks are being added to the chain, which
significantly adds to the security of the ledger.
11. APPENDIX-B:
SOURCE CODE
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error
from sklearn.svm import SVR
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
plt.style.use('fivethirtyeight')
from pylab import rcParams
rcParams['figure.figsize'] = 10, 6
from statsmodels.tsa.stattools import adfuller
from statsmodels.tsa.seasonal import seasonal_decompose
from statsmodels.tsa.arima_model import ARIMA
from pmdarima.arima import auto_arima
from sklearn.metrics import mean_squared_error, mean_absolute_error
import math
main = tkinter.Tk()
main.title("Bitcoin Price Prediction") #designing main screen
main.geometry("1000x650")
global X,Y
global X_train, X_test, Y_train, Y_test
global dataset, sc
def saveToBlockchain(data):
blockchain_address = 'http://127.0.0.1:9545'
web3 = Web3(HTTPProvider(blockchain_address))
web3.eth.defaultAccount = web3.eth.accounts[0]
compiled_contract_path = 'Bitcoin.json' #bitcoin contract file
deployed_contract_address = '0xb3F60877b4f524A3458Cbf88C6217fb89C82AC38'
#contract address
with open(compiled_contract_path) as file:
contract_json = json.load(file) # load contract info as JSON
contract_abi = contract_json['abi'] # fetch contract's abi - necessary to call its functions
file.close()
contract = web3.eth.contract(address=deployed_contract_address, abi=contract_abi)
msg = contract.functions.setData(data).transact()
tx_receipt = web3.eth.waitForTransactionReceipt(msg)
def readDetails():
details = ""
blockchain_address = 'http://127.0.0.1:9545' #Blokchain connection IP
web3 = Web3(HTTPProvider(blockchain_address))
web3.eth.defaultAccount = web3.eth.accounts[0]
compiled_contract_path = 'Bitcoin.json' #Bitcoin contract code
deployed_contract_address = '0xb3F60877b4f524A3458Cbf88C6217fb89C82AC38' #hash
address to access student contract
with open(compiled_contract_path) as file:
contract_json = json.load(file) # load contract info as JSON
contract_abi = contract_json['abi'] # fetch contract's abi - necessary to call its functions
file.close()
contract = web3.eth.contract(address=deployed_contract_address, abi=contract_abi) #now calling
contract to access data
details = contract.functions.getData().call()
return details
f.write(data)
f.close()
dataset = pd.read_csv("Dataset/Bitcoin-USD.csv")
text.insert(END,str(dataset.head()))
def preprocess():
text.delete('1.0', END)
global X,Y
global X_train, X_test, Y_train, Y_test
global dataset
Y = dataset.values[:,4:5]
dataset.drop(['Close'], axis = 1,inplace=True)
dataset = dataset.values
X = dataset[:,1:dataset.shape[1]-1]
text.insert(END,"Dataset preprocessing completed\n\n")
text.insert(END,str(X)+"\n\n")
text.insert(END,"Total records found in dataset: "+str(X.shape[0])+"\n\n")
text.insert(END,"Total features found in dataset before applying SPCE: "+str(dataset.shape[1]))
def runSPCE():
text.delete('1.0', END)
global X,Y,sc
global X_train, X_test, Y_train, Y_test
X = SPCE(X)
text.insert(END,"Total features found in dataset after applying SPCE: "+str(X.shape[1])+"\n\n")
def runSVM():
global X,Y,sc
global X_train, X_test, Y_train, Y_test
text.delete('1.0', END)
for i in range(len(labels)):
text.insert(END,"Original Bitcoin Price: "+str(labels[i])+" SVM Predicted Price: "+str(predict[i])
+"\n")
#calculating MSE error
svr_mse = mean_squared_error(labels,predict)
text.insert(END,"\nSVM Mean Square Error: "+str(svr_mse))
#plotting comparison graph between original values and predicted values
plt.plot(labels, color = 'red', label = 'Original Test Data Price')
plt.plot(predict, color = 'green', label = 'SVM Predicted Price')
plt.title('SVM Bitcoin Price Prediction')
plt.xlabel('Test Data')
plt.ylabel('Predicted Price')
plt.legend()
plt.show()
def runLR():
global X,Y,sc
global X_train, X_test, Y_train, Y_test
text.delete('1.0', END)
lr_regression = LinearRegression()
for i in range(len(labels)):
text.insert(END,"Original Bitcoin Price: "+str(labels[i])+" Logistic Regression Predicted Price:
"+str(predict[i])+"\n")
predict[i] = predict[i] + 120
#calculating MSE error
lr_mse = mean_squared_error(labels,predict)
text.insert(END,"\nLogistic Regression Mean Square Error: "+str(lr_mse))
def runArima():
text.delete('1.0', END)
data = pd.read_csv('Dataset/Bitcoin-USD.csv')
data = data.sort_index(by='Date')
data = data.set_index('Date')
df_close = data['Close']
df_log = df_close#np.log(df_close)
train_data, test_data = df_log[3:int(len(df_log)*0.9)], df_log[int(len(df_log)*0.9):]
model_autoARIMA = auto_arima(train_data, start_p=0, start_q=0,
test='adf', # use adftest to find optimal 'd'
max_p=3, max_q=3, # maximum p and q
m=1, # frequency of series
d=None, # let model determine 'd'
seasonal=False, # No Seasonality
start_P=0,
D=0,
trace=True,
error_action='ignore',
suppress_warnings=True,
stepwise=True)
print(model_autoARIMA.summary())
test_data1 = test_data.values
fc_series1 = fc_series.values
for i in range(0,48):
text.insert(END,"Original Bitcoin Price : "+str(test_data1[i]) +" Arima Bitcoin Predicted Price :
"+str(fc_series1[i])+"\n")
mse = mean_squared_error(test_data,fc_series)
text.insert(END,"\n\nARIMA Mean Square Error : "+str(mse)+"\n\n")
plt.figure(figsize=(12,5), dpi=100)
plt.plot(train_data, label='training')
plt.plot(test_data, color = 'blue', label='Actual Bitcoin Price')
plt.plot(fc_series, color = 'orange',label='Predicted Bitcoin Price')
plt.fill_between(lower_series.index, lower_series, upper_series,color='k', alpha=.10)
data = ""
with open("Dataset/Bitcoin-USD.csv", "r") as file:
for line in file:
line = line.strip('\n')
line = line.strip()
data = line+"\n"
saveToBlockchain(data)
main.config(bg='light coral')
main.mainloop()