Professional Documents
Culture Documents
Modeling and Predicting Cyber Hacking BR
Modeling and Predicting Cyber Hacking BR
Modeling and Predicting Cyber Hacking BR
HACKING BREACHES
ABSTRACT:
Analyzing cyber incident data sets is an important method for
deepening our understanding of the evolution of the threat situation. This
is a relatively new research topic, and many studies remain to be done.
In this paper, we report a statistical analysis of a breach incident data set
corresponding to 12 years (2005–2017) of cyber hacking activities that
include malware attacks. We show that, in contrast to the findings
reported in the literature, both hacking breach incident inter-arrival times
and breach sizes should be modeled by stochastic processes, rather than
by distributions because they exhibit autocorrelations. Then, we propose
particular stochastic process models to, respectively, fit the inter-arrival
times and the breach sizes. We also show that these models can predict
the inter-arrival times and the breach sizes. In order to get deeper
insights into the evolution of hacking breach incidents, we conduct both
qualitative and quantitative trend analyses on the data set. We draw a set
of cybersecurity insights, including that the threat of cyber hacks is
indeed getting worse in terms of their frequency, but not in terms of the
magnitude of their damage.
ARCHITECTURE:
EXISTING SYSTEM:
The present study is motivated by several questions that have not been
investigated until now, such as: Are data breaches caused by cyber-
attacks increasing, decreasing, or stabilizing? A principled answer to this
question will give us a clear insight into the overall situation of cyber
threats. This question was not answered by previous studies.
Specifically, the dataset analyzed in [7] only covered the time span from
2000 to 2008 and does not necessarily contain the breach incidents that
are caused by cyber-attacks; the dataset analyzed in [9] is more recent,
but contains two kinds of incidents: negligent breaches (i.e., incidents
caused by lost, discarded, stolen devices and other reasons) and
malicious breaching. Since negligent breaches represent more human
errors than cyber-attacks, we do not consider them in the present study.
Because the malicious breaches studied in [9] contain four sub-
categories: hacking (including malware), insider, payment card fraud,
and unknown, this study will focus on the hacking sub-category (called
hacking breach dataset thereafter), while noting that the other three sub-
categories are interesting on their own and should be analyzed
separately. Recently, researchers started modeling data breach incidents.
Maillart and Sornette studied the statistical properties of the personal
identity losses in the United States between year 2000 and 2008. They
found that the number of breach incidents dramatically increases from
2000 to July 2006 but remains stable thereafter. Edwards et al. analyzed
a dataset containing 2,253 breach incidents that span over a decade
(2005 to 2015). They found that neither the size nor the frequency of
data breaches has increased over the years. Wheatley et al., analyzed a
dataset that is combined from corresponds to organizational breach
incidents between year 2000 and 2015. They found that the frequency of
large breach incidents (i.e., the ones that breach more than 50,000
records) occurring to US firms is independent of time, but the frequency
of large breach incidents occurring to non-US firms exhibits an
increasing trend.
PROPOSED SYSTEM:
In this paper, we make the following three contributions. First, we
show that both the hacking breach incident interarrival times (reflecting
incident frequency) and breach sizes should be modeled by stochastic
processes, rather than by distributions. We find that a particular point
process can adequately describe the evolution of the hacking breach
incidents inter-arrival times and that a particular ARMA-GARCH model
can adequately describe the evolution of the hacking breach sizes, where
ARMA is acronym for “AutoRegressive and Moving Average” and
GARCH is acronym for “Generalized AutoRegressive Conditional
Heteroskedasticity.”We show that these stochastic process models can
predict the inter-arrival times and the breach sizes. To the best of our
knowledge, this is the first paper showing that stochastic processes,
rather than distributions, should be used to model these cyber threat
factors. Second, we discover a positive dependence between the
incidents inter-arrival times and the breach sizes, and show that this
dependence can be adequately described by a particular copula. We also
show that when predicting inter-arrival times and breach sizes, it is
necessary to consider the dependence; otherwise, the prediction results
are not accurate. To the best of our knowledge, this is the first work
showing the existence of this dependence and the consequence of
ignoring it. Third, we conduct both qualitative and quantitative trend
analyses of the cyber hacking breach incidents. We find that the
situation is indeed getting worse in terms of the incidents inter-arrival
time because hacking breach incidents become more and more frequent,
but the situation is stabilizing in terms of the incident breach size,
indicating that the damage of individual hacking breach incidents will
not get much worse. We hope the present study will inspire more
investigations, which can offer deep insights into alternate risk
mitigation approaches. Such insights are useful to insurance companies,
government agencies, and regulators because they need to deeply
understand the nature of data breach risks.
ALGORITHM:
SUPPORT VECTOR MACHINE
“Support Vector Machine” (SVM) is a supervised machine learning
algorithm which can be used for both classification and regression
challenges. However, it is mostly used in classification problems. In this
algorithm, we plot each data item as a point in n-dimensional space
(where n is number of features you have) with the value of each feature
being the value of a particular coordinate. Then, we perform
classification by finding the hyper-plane that differentiate the two
classes very well (look at the below snapshot). Support Vectors are
simply the co-ordinates of individual observation. Support Vector
Machine is a frontier which best segregates the two classes (hyper-plane/
line). More formally, a support vector machine constructs a hyper plane
or set of hyper planes in a high- or infinite-dimensional space, which can
be used for classification, regression, or other tasks like outliers
detection. Intuitively, a good separation is achieved by the hyper plane
that has the largest distance to the nearest training-data point of any class
(so-called functional margin), since in general the larger the margin the
lower the generalization error of the classifier. Whereas the original
problem may be stated in a finite dimensional space, it often happens
that the sets to discriminate are not linearly separable in that space. For
this reason, it was proposed that the original finite-dimensional space be
mapped into a much higher-dimensional space, presumably making the
separation easier in that space.
MODULES:
1. UPLOAD DATA
The data resource to database can be uploaded by both
administrator and authorized user. The data can be uploaded with
key in order to maintain the secrecy of the data that is not released
without knowledge of user. The users are authorized based on their
details that are shared to admin and admin can authorize each user.
Only Authorized users are allowed to access the system and upload
or request for files.
2. ACCESS DETAILS
The access of data from the database can be given by
administrators. Uploaded data are managed by admin and admin is
the only person to provide the rights to process the accessing details
and approve or unapproved users based on their details.
3. USER PERMISSIONS
The data from any resources are allowed to access the data with
only permission from administrator. Prior to access data, users are
allowed by admin to share their data and verify the details which are
provided by user. If user is access the data with wrong attempts then,
users are blocked accordingly. If user is requested to unblock them,
based on the requests and previous activities admin is unblock users.
4. DATA ANALYSIS
Data analyses are done with the help of graph. The collected
data are applied to graph in order to get the best analysis and
prediction of dataset and given data policies. The dataset can be
analyzed through this pictorial representation in order to better
understand of the data details.
FUTUREWORK:
There are many open problems that are left for future research. For
example, it is both interesting and challenging to investigate how to
predict the extremely large values and how to deal with missing data
(i.e., breach incidents that are not reported). It is also worthwhile to
estimate the exact occurring times of breach incidents. Finally, more
research needs to be conducted towards understanding the predictability
of breach incidents (i.e., the upper bound of prediction accuracy).
REQUIREMENT ANALYSIS
REQUIREMENT SPECIFICATION
Functional Requirements
Software Requirements
1. Python
2. Django
3. Mysql
4. Wampserver
1. Windows 7
2. Windows XP
3. Windows 8
1. Python
Python Introduction
Python is a general purpose, dynamic, high level, and interpreted programming language.
It supports Object Oriented programming approach to develop applications. It is simple and
easy to learn and provides lots of high-level data structures.
Python is easy to learn yet powerful and versatile scripting language, which makes it
attractive for Application Development.
Python's syntax and dynamic typing with its interpreted nature make it an ideal language
for scripting and rapid application development.
Python is not intended to work in a particular area, such as web programming. That is why
it is known as multipurpose programming language because it can be used with web,
enterprise, 3D CAD, etc.
We don't need to use data types to declare variable because it is dynamically typed so we
can write a=10 to assign an integer value in an integer variable.
Python makes the development and debugging fast because there is no compilation step
included in Python development, and edit-test-debug cycle is very fast.
1. Python 2 uses print as a statement and used as print "something" to print some
string on the console. On the other hand, Python 3 uses print as a function and used
as print("something") to print something on the console.
2. Python 2 uses the function raw_input() to accept the user's input. It returns the
string representing the value, which is typed by the user. To convert it into the
integer, we need to use the int() function in Python. On the other hand, Python 3
uses input() function which automatically interpreted the type of input entered by
the user. However, we can cast this value to any type by using primitive functions
(int(), str(), etc.).
3. In Python 2, the implicit string type is ASCII, whereas, in Python 3, the implicit string
type is Unicode.
4. Python 3 doesn't contain the xrange() function of Python 2. The xrange() is the
variant of range() function which returns a xrange object that works similar to Java
iterator. The range() returns a list for example the function range(0,3) contains 0, 1,
2.
5. There is also a small change made in Exception handling in Python 3. It defines a
keyword as which is necessary to be used. We will discuss it in Exception handling
section of Python programming tutorial.
next →← prev
Python Features
Python provides lots of features that are listed below.
2) Expressive Language
Python language is more expressive means that it is more understandable and readable.
3) Interpreted Language
Python is an interpreted language i.e. interpreter executes the code line by line at a time.
This makes debugging easy and thus suitable for beginners.
4) Cross-platform Language
Python can run equally on different platforms such as Windows, Linux, Unix and
Macintosh etc. So, we can say that Python is a portable language.
5) Free and Open Source
Python language is freely available at offical web address.The source-code is also
available. Therefore it is open source.
6) Object-Oriented Language
Python supports object oriented language and concepts of classes and objects come into
existence.
7) Extensible
It implies that other languages such as C/C++ can be used to compile the code and thus
it can be used further in our python code.
10) Integrated
It can be easily integrated with languages like C, C++, JAVA etc.
Python programming language is being updated regularly with new features and supports.
There are lots of updations in python versions, started from 1994 to current release.
next →← prev
Python Applications
Python is known for its general purpose nature that makes it applicable in almost each
domain of software development. Python as a whole can be used in any sphere of
development.
1) Web Applications
We can use Python to develop web applications. It provides libraries to handle internet
protocols such as HTML and XML, JSON, Email processing, request, beautifulSoup,
Feedparser etc. It also provides Frameworks such as Django, Pyramid, Flask etc to
design and delelop web based applications. Some important developments are:
PythonWikiEngines, Pocoo, PythonBlogSoftware etc.
5) Business Applications
Python is used to build Bussiness applications like ERP and e-commerce systems. Tryton
is a high level application platform.
8) 3D CAD Applications
To create CAD application Fandango is a real application which provides full features of
CAD.
9) Enterprise Applications
Python can be used to create applications which can be used within an Enterprise or an
Organization. Some real time applications are: OpenErp, Tryton, Picalo etc.
There are several such applications which can be developed using Python
next →← prev
How to Install Python (Environment
Set-up)
In this section of the tutorial, we will discuss the installation of python on various
operating systems.
Installation on Windows
Visit the link https://www.python.org/downloads/ to download the latest release of
Python. In this process, we will install Python 3.6.7 on our Windows operating system.
Double-click the executable file which is downloaded; the following window will open.
Select Customize installation and proceed.
The following window shows all the optional features. All the features need to be installed
and are checked by default; we need to click next to continue.
The following window shows a list of advanced options. Check all the options which you
want to install and click next. Here, we must notice that the first check-box (install for all
users) must be checked.
next →← prev
To open the interactive mode, open the terminal (or command prompt) and type python
(python3 in case if you have python2 and python3 both installed on your system).
It will open the following prompt where we can execute the python statement and check
their impact on the console.
Let's run a python statement to print the traditional hello world on the console. Python3
provides print() function to print some message on the console. We can pass the
message as a string into this function. Consider the following image.
Here, we get the message "Hello World !" printed on the console.
We need to write our code into a file which can be executed later. For this purpose, open
an editor like notepad, create a file named first.py (python used .py extension) and write
the following code in it.
1. Print ("hello world"); #here, we have used print() function to print the message on the c
onsole.
To run this file named as first.py, we need to run the following command on the terminal.
$ python3 first.py
Hence, we get our output as the message Hello World ! is printed on the console.
PyCharm installation
As we have already stated, PyCharm is a cross-platform IDE, and hence it can be
installed on a variety of the operating systems. In this section of the tutorial, we will
cover the installation process of PyCharm on Windows, MacOS, CentOS, and Ubuntu.
Windows
Installing PyCharm on Windows is very simple. To install PyCharm on Windows operating
system, visit the link https://www.jetbrains.com/pycharm/download/download-thanks.html?
platform=windows to download the executable installer. Double click the installer (.exe)
file and install PyCharm by clicking next at each step.
next →← prev
Python Variables
Variable is a name which is used to refer memory location. Variable also known as
identifier and used to hold value.
In Python, we don't need to specify the type of variable because Python is a type infer
language and smart enough to get variable type.
Variable names can be a group of both letters and digits, but they have to begin with a
letter or an underscore.
It is recomended to use lowercase letters for variable name. Rahul and rahul both are
two different variables.
Identifier Naming
Variables are the example of identifiers. An Identifier is used to identify the literals used
in the program. The rules to name an identifier are given below.
We don't need to declare explicitly variable in Python. When we assign any value to the
variable that variable is declared automatically.
Eg:
Output:
1. >>>
2. 10
3. ravi
4. 20000.67
5. >>>
Multiple Assignment
Python allows us to assign a value to multiple variables in a single statement which is
also known as multiple assignment.
We can apply multiple assignments in two ways either by assigning a single value to
multiple variables or assigning multiple values to multiple variables. Lets see given
examples.
Eg:
1. x=y=z=50
2. print iple
3. print y
4. print z
Output:
1. >>>
2. 50
3. 50
4. 50
5. >>>
2.Assigning multiple values to multiple variables:
Eg:
1. a,b,c=5,10,15
2. print a
3. print b
4. print c
Output:
1. >>>
2. 5
3. 10
4. 15
5. >>>
The values will be assigned in the order in which variables appears.
Basic Fundamentals:
This section contains the basic fundamentals of Python like :
ii) Comments
a)Tokens:
o Tokens can be defined as a punctuator mark, reserved words and each individual
word in a statement.
o Token is the smallest unit inside the given program.
o Keywords.
o Identifiers.
o Literals.
o Operators.
Tuples:
o Tuple is another form of collection where different type of data can be stored.
o It is similar to list where data is separated by commas. Only the difference is that
list uses square bracket and tuple uses parenthesis.
o Tuples are enclosed in parenthesis and cannot be changed.
Eg:
1. >>> tuple=('rahul',100,60.4,'deepak')
2. >>> tuple1=('sanjay',10)
3. >>> tuple
4. ('rahul', 100, 60.4, 'deepak')
5. >>> tuple[2:]
6. (60.4, 'deepak')
7. >>> tuple1[0]
8. 'sanjay'
9. >>> tuple+tuple1
10. ('rahul', 100, 60.4, 'deepak', 'sanjay', 10)
11. >>>
Dictionary:
o Dictionary is a collection which works on a key-value pair.
o It works like an associated array where no two keys can be same.
o Dictionaries are enclosed by curly braces ({}) and values can be retrieved by
square bracket([]).
Eg:
1. >>> dictionary={'name':'charlie','id':100,'dept':'it'}
2. >>> dictionary
3. {'dept': 'it', 'name': 'charlie', 'id': 100}
4. >>> dictionary.keys()
5. ['dept', 'name', 'id']
6. >>> dictionary.values()
7. ['it', 'charlie', 100]
8. >>>
next →← prev
Python enables us to check the type of the variable used in the program. Python provides
us the type() function which returns the type of the variable passed.
Consider the following example to define the values of different data types and checking
its type.
1. A=10
2. b="Hi Python"
3. c = 10.5
4. print(type(a));
5. print(type(b));
6. print(type(c));
Output:
<type 'int'>
<type 'str'>
<type 'float'>
Python provides various standard data types that define the storage method on each of
them. The data types defined in Python are given below.
1. Numbers
2. String
3. List
4. Tuple
5. Dictionary
In this section of the tutorial, we will give a brief introduction of the above data types.
We will discuss each one of them in detail later in this tutorial.
Numbers
Number stores numeric values. Python creates Number objects when a number is
assigned to a variable. For example;
Python allows us to use a lower-case L to be used with long integers. However, we must
always use an upper-case L to avoid confusion.
A complex number contains an ordered pair, i.e., x + iy where x and y denote the real
and imaginary parts respectively).
String
The string can be defined as the sequence of characters represented in the quotation
marks. In python, we can use single, double, or triple quotes to define a string.
String handling in python is a straightforward task since there are various inbuilt
functions and operators provided.
In the case of string handling, the operator + is used to concatenate two strings as the
operation "hello"+" python" returns "hello python".
The operator * is known as repetition operator as the operation "Python " *2 returns
"Python Python ".
he
o
hello javatpointhello javatpoint
hello javatpoint how are you
List
Lists are similar to arrays in C. However; the list can contain data of different types. The
items stored in the list are separated with a comma (,) and enclosed within square
brackets [].
We can use slice [:] operators to access the data of the list. The concatenation operator
(+) and repetition operator (*) works with the list in the same way as they were working
with the strings.
[2]
[1, 'hi']
[1, 'hi', 'python', 2]
[1, 'hi', 'python', 2, 1, 'hi', 'python', 2]
[1, 'hi', 'python', 2, 1, 'hi', 'python', 2, 1, 'hi', 'python', 2]
Tuple
A tuple is similar to the list in many ways. Like lists, tuples also contain the collection of
the items of different data types. The items of the tuple are separated with a comma (,)
and enclosed in parentheses ().
A tuple is a read-only data structure as we can't modify the size and value of the items of
a tuple.
1. t = ("hi", "python", 2)
2. print (t[1:]);
3. print (t[0:1]);
4. print (t);
5. print (t + t);
6. print (t * 3);
7. print (type(t))
8. t[2] = "hi";
Output:
('python', 2)
('hi',)
('hi', 'python', 2)
('hi', 'python', 2, 'hi', 'python', 2)
('hi', 'python', 2, 'hi', 'python', 2, 'hi', 'python', 2)
<type 'tuple'>
Traceback (most recent call last):
File "main.py", line 8, in <module>
t[2] = "hi";
TypeError: 'tuple' object does not support item assignment
Dictionary
Dictionary is an ordered set of a key-value pair of items. It is like an associative array or
a hash table where each key stores a specific value. Key can hold any primitive data type
whereas value is an arbitrary Python object.
The items in the dictionary are separated with the comma and enclosed in the curly
braces {}.
next →← prev
Python Functions
Functions are the most important aspect of an application. A function can be defined as
the organized block of reusable code which can be called whenever required.
Python allows us to divide a large program into the basic building blocks known as
function. The function contains the set of programming statements enclosed by {}. A
function can be called multiple times to provide reusability and modularity to the python
program.
In other words, we can say that the collection of functions creates a program. The
function is also known as procedure or subroutine in other programming languages.
Python provide us various inbuilt functions like range() or print(). Although, the user can
create its functions which can be called user-defined functions.
o By using functions, we can avoid rewriting same logic/code again and again in a
program.
o We can call python functions any number of times in a program and from any
place in a program.
o We can track a large python program easily when it is divided into multiple
functions.
o Reusability is the main achievement of python functions.
o However, Function calling is always overhead in a python program.
Creating a function
In python, we can use def keyword to define the function. The syntax to define a
function in python is given below.
1. def my_function():
2. function-suite
3. return <expression>
The function block is started with the colon (:) and all the same level block statements
remain at the same indentation.
A function can accept any number of parameters that must be the same in the definition
and function calling.
Function calling
In python, a function must be defined before the function calling otherwise the python
interpreter gives an error. Once the function is defined, we can call it from another
function or the python prompt. To call the function, use the function name followed by
the parentheses.
A simple function that prints the message "Hello Word" is given below.
1. def hello_world():
2. print("hello world")
3.
4. hello_world()
Output:
hello world
Parameters in function
The information into the functions can be passed as the parameters. The parameters are
specified in the parentheses. We can give any number of parameters, but we have to
separate them with a comma.
Consider the following example which contains a function that accepts a string as the
parameter and prints it.
Example 1
Example 2
1. #python function to calculate the sum of two variables
2. #defining the function
3. def sum (a,b):
4. return a+b;
5.
6. #taking values from the user
7. a = int(input("Enter a: "))
8. b = int(input("Enter b: "))
9.
10. #printing the sum of a and b
11. print("Sum = ",sum(a,b))
Output:
Enter a: 10
Enter b: 20
Sum = 30
However, there is an exception in the case of mutable objects since the changes made to
the mutable objects like string do not revert to the original string rather, a new string
object is made, and therefore the two different objects are printed.
Types of arguments
There may be several types of arguments which can be passed at the time of function
calling.
1. Required arguments
2. Keyword arguments
3. Default arguments
4. Variable-length arguments
Required Arguments
Till now, we have learned about function calling in python. However, we can provide the
arguments at the time of function calling. As far as the required arguments are
concerned, these are the arguments which are required to be passed at the time of
function calling with the exact match of their positions in the function call and function
definition. If either of the arguments is not provided in the function call, or the position of
the arguments is changed, then the python interpreter will show the error.
Example 1
Hi John
Example 2
1. #the function simple_interest accepts three arguments and returns the simple interest ac
cordingly
2. def simple_interest(p,t,r):
3. return (p*t*r)/100
4. p = float(input("Enter the principle amount? "))
5. r = float(input("Enter the rate of interest? "))
6. t = float(input("Enter the time in years? "))
7. print("Simple Interest: ",simple_interest(p,r,t))
Output:
Example 3
Keyword arguments
Python allows us to call the function with the keyword arguments. This kind of function
call will enable us to pass the arguments in the random order.
The name of the arguments is treated as the keywords and matched in the function
calling and definition. If the same match is found, the values of the arguments are copied
in the function definition.
Example 1
1. #function func is called with the name and message as the keyword arguments
2. def func(name,message):
3. print("printing the message with",name,"and ",message)
4. func(name = "John",message="hello") #name and message is copied with the values Joh
n and hello respectively
Output:
1. #The function simple_interest(p, t, r) is called with the keyword arguments the order of
arguments doesn't matter in this case
2. def simple_interest(p,t,r):
3. return (p*t*r)/100
4. print("Simple Interest: ",simple_interest(t=10,r=10,p=1900))
Output:
Example 3
The python allows us to provide the mix of the required arguments and keyword
arguments at the time of function call. However, the required argument must not be
given after the keyword argument, i.e., once the keyword argument is encountered in
the function call, the following arguments must also be the keyword arguments.
Example 4
1. def func(name1,message,name2):
2. print("printing the message with",name1,",",message,",and",name2)
3. func("John",message="hello",name2="David") #the first argument is not the keyword ar
gument
Output:
The following example will cause an error due to an in-proper mix of keyword and
required arguments being passed in the function call.
Example 5
1. def func(name1,message,name2):
2. print("printing the message with",name1,",",message,",and",name2)
3. func("John",message="hello","David")
Output:
Default Arguments
Python allows us to initialize the arguments at the function definition. If the value of any
of the argument is not provided at the time of function call, then that argument can be
initialized with the value given in the definition even if the argument is not specified at
the function call.
Example 1
1. def printme(name,age=22):
2. print("My name is",name,"and age is",age)
3. printme(name = "john") #the variable age is not passed into the function however the d
efault value of age is considered in the function
Output:
Example 2
1. def printme(name,age=22):
2. print("My name is",name,"and age is",age)
3. printme(name = "john") #the variable age is not passed into the function however the d
efault value of age is considered in the function
4. printme(age = 10,name="David") #the value of age is overwritten here, 10 will be printe
d as age
Output:
Example
1. def printme(*names):
2. print("type of passed argument is ",type(names))
3. print("printing the passed arguments...")
4. for name in names:
5. print(name)
6. printme("john","David","smith","nick")
Output:
john
David
smith
nick
Scope of variables
The scopes of the variables depend upon the location where the variable is being
declared. The variable declared in one part of the program may not be accessible to the
other parts.
In python, the variables are defined with the two types of scopes.
1. Global variables
2. Local variables
The variable defined outside any function is known to have a global scope whereas the
variable defined inside a function is known to have a local scope.
Example 1
1. def print_message():
2. message = "hello !! I am going to print a message." # the variable message is local to
the function itself
3. print(message)
4. print_message()
5. print(message) # this will cause an error since a local variable cannot be accessible here
.
Output:
print(message)
Example 2
1. def calculate(*args):
2. sum=0
3. for arg in args:
4. sum = sum +arg
5. print("The sum is",sum)
6. sum=0
7. calculate(10,20,30) #60 will be printed as the sum
8. print("Value of sum outside the function:",sum) # 0 will be printed
Output:
The sum is 60
Value of sum outside the function: 0
next →← prev
Python Class and Objects
As we have already discussed, a class is a virtual entity and can be seen as a blueprint of
an object. The class came into existence when it instantiated. Let's understand it by an
example.
Suppose a class is a prototype of a building. A building contains all the details about the
floor, doors, windows, etc. we can make as many buildings as we want, based on these
details. Hence, the building can be seen as a class, and we can create as many objects of
this class.
On the other hand, the object is the instance of a class. The process of creating an object
can be called as instantiation.
In this section of the tutorial, we will discuss creating classes and objects in python. We
will also talk about how an attribute is accessed by using the class object.
Syntax
1. class ClassName:
2. #statement_suite
In python, we must notice that each class is associated with a documentation string
which can be accessed by using <class-name>.__doc__. A class contains a statement
suite including fields, constructor, function, etc. definition.
Consider the following example to create a class Employee which contains two fields as
Employee id, and name.
The class also contains a function display() which is used to display the information of
the Employee.
Example
1. class Employee:
2. id = 10;
3. name = "ayush"
4. def display (self):
5. print(self.id,self.name)
Here, the self is used as a reference variable which refers to the current class object. It is
always the first argument in the function definition. However, using self is optional in the
function call.
1. <object-name> = <class-name>(<arguments>)
The following example creates the instance of the class Employee defined in the above
example.
Example
1. class Employee:
2. id = 10;
3. name = "John"
4. def display (self):
5. print("ID: %d \nName: %s"%(self.id,self.name))
6. emp = Employee()
7. emp.display()
Output:
ID: 10
Name: ayush
next →← prev
DJANGO
Introduction
Django is a web application framework written in Python programming language. It is
based on MVT (Model View Template) design pattern. The Django is very demanding due
to its rapid development feature. It takes less time to build application after collecting
client requirement.
This framework uses a famous tag line:The web framework for perfectionists with
deadlines.
By using Django, we can build web applications in very less time. Django is designed in
such a manner that it handles much of configure things automatically, so we can focus
on application development only.
History
Django was design and developed by Lawrence journal world in 2003 and publicly
released under BSD license in July 2005. Currently, DSF (Django Software Foundation)
maintains its development and release cycle.
Django was released on 21, July 2005. Its current stable version is 2.0.3 which was
released on 6 March, 2018.
next →← prev
Features of Django
o Rapid Development
o Secure
o Scalable
o Fully loaded
o Versatile
o Open Source
o Vast and Supported Community
Rapid Development
Django was designed with the intention to make a framework which takes less time to
build web application. The project implementation phase is a very time taken but Django
creates it rapidly.
Secure
Django takes security seriously and helps developers to avoid many common security
mistakes, such as SQL injection, cross-site scripting, cross-site request forgery etc. Its
user authentication system provides a secure way to manage user accounts and
passwords.
Scalable
Django is scalable in nature and has ability to quickly and flexibly switch from small to
large scale application project.
Fully loaded
Django includes various helping task modules and libraries which can be used to handle
common Web development tasks. Django takes care of user authentication, content
administration, site maps, RSS feeds etc.
Versatile
Django is versatile in nature which allows it to build applications for different-different
domains. Now a days, Companies are using Django to build various types of applications
like: content management systems, social networks sites or scientific computing
platforms etc.
Open Source
Django is an open source web application framework. It is publicly available without cost.
It can be downloaded with source code from the public repository. Open source reduces
the total cost of the application development.
next →← prev
Django Installation
To install Django, first visit to django official site
(https://www.djangoproject.com) and download django by clicking on the download
section. Here, we will see various options to download The Django.
Django requires pip to start installation. Pip is a package manager system which is used
to install and manage packages written in python. For Python 3.4 and higher
versions pip3 is used to manage packages.
The complete installation process is described below. Before installing make sure pip is
installed in local system.
Here, we are installing Django using pip3, the installation command is given below.
next →← prev
Django Project
In the previous topic, we have installed Django successfully. Now, we will learn step by
step process to create a Django application.
To create a Django project, we can use the following command. projectname is the name
of Django application.
1. cd djangpapp
To see all the files and subfolders of django project, we can use tree command to view
the tree structure of the application. This is a utility command, if it is not present, can be
downloaded via apt-get install tree command.
A Django project contains the following packages and files. The outer directory is just a
container for the application. We can rename it further.
Initially, this project is a default draft which contains all the required files and folders.
Look server has started and can be accessed at localhost with port 8000. Let's access it
using the browser, it looks like the below.
This command starts the server which runs on port 8000 and can be accessed at browser
by entering localhost:8000. It shows a welcome page of the application.
// apache2.conf
1. WSGIScriptAlias / /var/www/html/django7/django7/wsgi.py
2. WSGIPythonPath /var/www/html/django7/
3.
4. <Directory /var/www/html/django7>
5. <Files wsgi.py>
6. Require all granted
7. </Files>
8. </Directory>
After adding these lines, restart apache server by using the service apache2
restart command and then type localhost to the browser's address bar. This time,
project will run on apache server rather than a built-in server. See, it shows the home
page of the application.
next →← prev
1. Install Package
1. $ mkdir djangoenv
After it, change directory to the newly created directory by using the cd djangoenv.
1. $ source djangoenv/bin/activate
Till here, the virtual environment has started. Now, we can use it to create Django
application.
Install Django
Install Django in the virtual environment. To install Django, use the following command.
Django has installed successfully. Now we can create a new project and build new
applications in the separate environment
next →← prev
This is a built-in module and designed to perform admin related tasks to the user.
Let's see how to activate and use Django's admin module (interface).
The admin app (django.contrib.admin) is enabled by default and already added into
INSTALLED_APPS section of the settings file.
next →← prev
Django App
In the previous topics, we have seen a procedure to create a Django project. Now, in this
topic, we will create app inside the created project.
Django application consists of project and app, it also generates an automatic base
directory for the app, so we can focus on writing code (business logic) rather than
creating app directories.
The difference between a project and app is, a project is a collection of configuration files
and apps whereas the app is a web application which is written to perform business logic.
Creating an App
To create an app, we can use the following command.
See the directory structure of the created app, it contains the migrations folder to store
migration files and model to write business logic.
Initially, all the files are empty, no code is available but we can use these to implement
business logic on the basis of the MVC design pattern.
To run this application, we need to make some significant changes which display hello
world message on the browser.
Open views.py file in any text editor and write the given code to it and do the same
for urls.py file too.
// views.py
Open any web browser and enter the URL localhost:8000/hello. It will show the output
given below.
next →← prev
Django MVT
The MVT (Model View Template) is a software design pattern. It is a collection of three
important components Model View and Template. The Model helps to handle database. It
is a data access layer which handles the data.
The Template is a presentation layer which handles User Interface part completely. The
View is used to execute the business logic and interact with a model to carry data and
renders a template.
Although Django follows MVC pattern but maintains it?s own conventions. So, control is
handled by the framework itself.
There is no separate controller and complete application is based on Model View and
Template. That?s why it is called MVT application.
See the following graph that shows the MVT based control flow.
Here, a user requests for a resource to the Django, Django works as a controller and
check to the available resource in URL.
If URL maps, a view is called that interact with model and template, it renders a
template.
next →← prev
Django Views
A view is a place where we put our business logic of the application. The view is a python
function which is used to perform some business logic and return a response to the user.
This response can be the HTML contents of a Web page, or a redirect, or a 404 error.
All the view function are created inside the views.py file of the Django app.
1. import datetime
2. # Create your views here.
3. from django.http import HttpResponse
4. def index(request):
5. now = datetime.datetime.now()
6. html = "<html><body><h3>Now time is %s.</h3></body></html>" % now
7. return HttpResponse(html) # rendering the template in HttpResponse
Let's step through the code.
First, we will import DateTime library that provides a method to get current date and
time and HttpResponse class.
Next, we define a view function index that takes HTTP request and respond back.
View calls when gets mapped with URL in urls.py. For example
1. path('index/', views.index),
Output:
UMLDIAGRAMS:
user
Admin
CLASS DIAGRAM:
SEQUENCE DIAGRAM:
SYSTEM TEST
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.
TYPES OF TESTS
Unit testing
Unit testing involves the design of test cases that validate that the internal
program logic is functioning properly, and that program inputs produce valid outputs. All
decision branches and internal code flow should be validated. It is the testing of individual
software units of the application .it is done after the completion of an individual unit before
integration. This is a structural testing, that relies on knowledge of its construction and is
invasive. Unit tests perform basic tests at component level and test a specific business process,
application, and/or system configuration. Unit tests ensure that each unique path of a business
process performs accurately to the documented specifications and contains clearly defined inputs
and expected results.
Integration testing
Integration tests are designed to test integrated software components to
determine if they actually run as one program. Testing is event driven and is more concerned
with the basic outcome of screens or fields. Integration tests demonstrate that although the
components were individually satisfaction, as shown by successfully unit testing, the
combination of components is correct and consistent. Integration testing is specifically aimed at
exposing the problems that arise from the combination of components.
Functional test
Functional tests provide systematic demonstrations that functions tested are
available as specified by the business and technical requirements, system documentation, and
user manuals.
Functional testing is centered on the following items:
System Test
System testing ensures that the entire integrated software system meets
requirements. It tests a configuration to ensure known and predictable results. An example of
system testing is the configuration oriented system integration test. System testing is based on
process descriptions and flows, emphasizing pre-driven process links and integration points.
Unit testing is usually conducted as part of a combined code and unit test phase
of the software lifecycle, although it is not uncommon for coding and unit testing to be
conducted as two distinct phases.
Features to be tested
Verify that the entries are of the correct format
No duplicate entries should be allowed
All links should take the user to the correct page.
Integration Testing
Software integration testing is the incremental integration testing of two or more
integrated software components on a single platform to produce failures caused by interface
defects.
The task of the integration test is to check that components or software applications, e.g.
components in a software system or – one step up – software applications at the company level –
interact without error.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
Acceptance Testing
User Acceptance Testing is a critical phase of any project and requires significant participation
by the end user. It also ensures that the system meets the functional requirements.
Test Results: All the test cases mentioned above passed successfully. No defects encountered.
LITERATURE SURVEY
Literature survey is the most important step in software development
process. Before developing the tool it is necessary to determine the time factor,
economy and company strength. Once these things are satisfied, ten next steps
are to determine which operating system and language can be used for
developing the tool. Once the programmers start building the tool the
programmers need lot of external support. This support can be obtained from
senior programmers, from book or from websites. Before building the system the
above consideration are taken into account for developing the proposed system.
This paper features a software system called ∞Exams (Infinity Exams) which supports (primarily
in higher education) paper-based examination and makes it easier, more comfortable and speeds
up the whole process while keeping every single positive attribute of it but also reducing the
number of negative aspects. The approach significantly differs from the ones used in the
previous 10+ years which were implemented in such a way that they could not reproduce and
replace the traditional paper-based examination model. The heart of the article relies on the most
important element of the software which is the image processing flow.The way of conducting
testing the knowledge of a person using Multiple Choice Questions (MCQ) has been increased
gradually. In Educational industries (like schools and colleges) it is more common now days
having tests using multiple choice questions. Even in conducting interviews it is used. Current
day scenario is either using OMR technology to correct the test or manually. In real-time it is
quite difficult to have OMR at all the time and manually it is highly taking the time to correct
and it may give you the error. We address this issue, in our proposed system we using digital
image processing technique to correct the answer using multi choice question in python. We are
here using Open Source Computer Vision Library (Open CV) to process and correct the answer.
Python is the best language to implement this concept with the available Open CV library. In this
system we also implement in the django environment. There is a growing need for storing paper-
based information digitalized nowadays. This problem concerns education as well but it does not
always get enough attention, however using our technology accordingly many aspects of the
educational process could be made a lot simpler, easier, faster, more comfortable and (partially)
automatable. Most of the educational institutions are using traditional teaching and examination
methods in most of their subjects still. Though the digitalization of teaching got a little bit of
attention in the previous years and began its growth since then. Alongside it there are also
computer-based examination methods but it is not the main functionality of the e-learning
systems. So mostly the traditional examination models are used concerning those subjects who
require such a way to be examined accordingly. From now on the paper-based examination
method will be discussed, since it is the main concern of this paper. The keyword “e-assessment”
refers to electronic assessment as software is used to mark the exam papers filled by the students
after the exam is completed. Multiple choices Question (MCQ) are a form of an objective
assessment in which respondents are asked to select only correct answers out of the choices from
a list.[1] The multiple choice format is most frequently used in educational testing, in market
research, and in elections, when a person chooses between multiple candidates, parties, or
policies. In this paper we are using image processing to accomplish the MCQ correction in very
easy manner. It produces the great effort to deal to remove the barriers of multi choice
assessment correction. In this we are using array format to correct the answer paper which is
photo copier and uploaded by user. The main concept is to get the image and get the answer
which is shadowed by user. In Python Open CV library is available for image processing. In
order to get the best effective output we use the django framework along with python. The Open
CV is a library of programming functions mainly aimed at real-time computer vision. The
Following topics are organized to explain the process of how to deal with this technique.
TITLE: INTELLIGENT SHORT TEXT ASSESSMENT IN EMAX
AUTHOR’S:
1. Dezso Sima
2. Balazs Schmuck
3. Sandor Szollosi
4. Arpad Miklos
Rapidly increasing student numbers and spreading distance learning systems strengthen the urgent
need for effective Knowledge Assessment Systems (KAS’s). Recent KAS’s have however, the deficiency of
not providing intelligent assessment modules for e.g. the evaluation of freely formulated short answers
including a few sentences or partially solved mathematical problems. The eMax KAS, developed at the
Intelligent Knowledge Management Innovation Center of IBM Hungary and the John von Neumann
Faculty of Informatics at Budapest Tech, aims to provide these capabilities. Our paper gives an
introduction to the intelligent assessment of short texts component of eMax by presenting the approach
used for the formal description of the “answer space” defined as well as the methods chosen for the
syntactic analysis, semantic analysis and scoring. The α version of eMax is now completed and is in
testing In the last decade student enrollment to our faculty has steadily grown, nearly five-fold in ten
years. The annual intake to our Engineer Informatics program approaches already 400 direct and 100
part time students. With such a large number of students, the assessment of midterm and final exams
require a huge effort from our faculty members. In order to substantially ease the burden of assessing
large numbers of exam questions while avoiding the constraints of passive answer types, such as
multiple-choice questions, an internal project was launched five years ago with the goal of developing
an intelligent knowledge assessment system (KAS). In the first phase of the project, a wide range
literature research was conducted [1], [2] and a test system called Evita [3] was developed to check the
feasibility of our ideas concerning the assessment of freely formulated short texts. Based on positive
results obtained, an Intelligent Knowledge Management Innovation Center was established in 2005
jointly by IBM Hungary and the John von Neumann Faculty of Informatics at Budapest Tech to develop
an appropriate intelligent KAS. The research and development work performed has resulted in the α
version of the eMax system, now under testing. Beyond the usual passive question types, eMax is able
to semi-automatically assess freely formulated short student answers and partially solved mathematical
problems as well. Unlike Automated Essay Grading (AEG) published widely [4],[5] the short text module
of our eMax is constrained only to a few (say 2-3) sentences and is based on a formal semantic
description rather than on methods used in AEG, such as statistical or Natural Language Processing (NLP)
techniques. Our paper and a companion paper [6] give an account of the two intelligent assessment
modules developed as parts of eMax