Code covered by the BSD License  

Highlights from
IDS Performance Metrics Calculator

from IDS Performance Metrics Calculator by Maher Salem
This code helps to calculate IDS performance metrics such as Accuracy, Precision, etc...

Evaluation(varargin)
function varargout = Evaluation(varargin)
% EVALUATION MATLAB code for Evaluation.fig
%      EVALUATION, by itself, creates a new EVALUATION or raises the existing
%      singleton*.
%
%      H = EVALUATION returns the handle to a new EVALUATION or the handle to
%      the existing singleton*.
%
%      EVALUATION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in EVALUATION.M with the given input arguments.
%
%      EVALUATION('Property','Value',...) creates a new EVALUATION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Evaluation_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Evaluation_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Evaluation

% Last Modified by GUIDE v2.5 04-Apr-2013 17:40:12

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Evaluation_OpeningFcn, ...
                   'gui_OutputFcn',  @Evaluation_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Evaluation is made visible.
function Evaluation_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Evaluation (see VARARGIN)

% Choose default command line output for Evaluation
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Evaluation wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Evaluation_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function TN_Callback(hObject, eventdata, handles)
% hObject    handle to TN (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of TN as text
%        str2double(get(hObject,'String')) returns contents of TN as a double


% --- Executes during object creation, after setting all properties.
function TN_CreateFcn(hObject, eventdata, handles)
% hObject    handle to TN (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function FN_Callback(hObject, eventdata, handles)
% hObject    handle to FN (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of FN as text
%        str2double(get(hObject,'String')) returns contents of FN as a double


% --- Executes during object creation, after setting all properties.
function FN_CreateFcn(hObject, eventdata, handles)
% hObject    handle to FN (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function FP_Callback(hObject, eventdata, handles)
% hObject    handle to FP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of FP as text
%        str2double(get(hObject,'String')) returns contents of FP as a double


% --- Executes during object creation, after setting all properties.
function FP_CreateFcn(hObject, eventdata, handles)
% hObject    handle to FP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function TP_Callback(hObject, eventdata, handles)
% hObject    handle to TP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of TP as text
%        str2double(get(hObject,'String')) returns contents of TP as a double


% --- Executes during object creation, after setting all properties.
function TP_CreateFcn(hObject, eventdata, handles)
% hObject    handle to TP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in calculate.
function calculate_Callback(hObject, eventdata, handles)
% hObject    handle to calculate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% claculate the performance parameters here 
TNR = (str2double(get(handles.TN,'String'))/(str2double(get(handles.TN,'String'))+ str2double(get(handles.FP,'String')))); 
set(handles.TNR_value,'String',TNR);

DR = (str2double(get(handles.TP,'String'))/(str2double(get(handles.TP,'String'))+ str2double(get(handles.FN,'String')))); 
set(handles.DR_value,'String',DR);

FPR = 1-TNR;
set(handles.FPR_value,'String',FPR);

FNR = 1-DR;
set(handles.FNR_value,'String',FNR);

ACC = ((str2double(get(handles.TN,'String'))+str2double(get(handles.TP,'String')))/(str2double(get(handles.TN,'String'))+ str2double(get(handles.TP,'String'))+str2double(get(handles.FP,'String'))+str2double(get(handles.FN,'String'))));
set(handles.Acc_value,'String',ACC);

PRE = (str2double(get(handles.TP,'String'))/(str2double(get(handles.TP,'String'))+ str2double(get(handles.FP,'String'))));
set(handles.Pre_value,'String',PRE);

%str2double(get(hObject,'String'))


% --- Executes on button press in exit.
function exit_Callback(hObject, eventdata, handles)
% hObject    handle to exit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

delete(handles.figure1);

% pos_size = get(handles.figure1,'Position');
% user_response = close('Title','Exit Application');
% switch user_response
% case {'No'}
%     % take no action
% case 'Yes'
% delete(handles.figure1);


% --- Executes on button press in reset.
function reset_Callback(hObject, eventdata, handles)
% hObject    handle to reset (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

set(handles.Pre_value,'String','value');
set(handles.Acc_value,'String','value');
set(handles.TNR_value,'String','value');
set(handles.DR_value,'String','value');
set(handles.FPR_value,'String','value');
set(handles.FNR_value,'String','value');
set(handles.TN,'String','');
set(handles.TP,'String','');
set(handles.FP,'String','');
set(handles.FN,'String','');


% --- Executes on button press in info.
function info_Callback(hObject, eventdata, handles)
% hObject    handle to info (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
msgbox(sprintf('The calculation is driven based on the following:\nTNR=(TN / TN+FP) \nDR=( TP / TP+FN) \nFPR=(1-TNR)  \nFNR=(1-DR) \nAccuracy=(TN+TP / TN+TP+FN+FP) \nPrecision=(TP / TP+FP). \nWhere: \nFP: The chance that there is an alert when there is no intrusion. \nTP: The chance the there is an alert when there is an intrusion. \nFN: The chance there is no alert when there is an intrusion. \nTN: The chance there is no alert when there is no intrusion'),'More info','help');

Contact us