403Webshell
Server IP : 172.64.80.1  /  Your IP : 172.70.131.126
Web Server : Apache
System : Linux mail.federalpolyede.edu.ng 5.10.0-32-amd64 #1 SMP Debian 5.10.223-1 (2024-08-10) x86_64
User : federalpolyede.edu.ng_idh35skikv ( 10000)
PHP Version : 7.4.33
Disable Function : opcache_get_status
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/vhosts/federalpolyede.edu.ng/phd_code/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/federalpolyede.edu.ng/phd_code/success_rate_real_table.py
import matplotlib.pyplot as plt, numpy as np
import pandas as pd

import os

# Specify the path and filename of the Excel file
filename = 'SR_output_1.xlsx'

# Check if the file exists
if os.path.exists(filename):
    # Delete the file
    os.remove(filename)
data = {
    'cycle':[0], 
    'level-0':[0],
    'level-1':[0],
    'level-2':[0],
    'level-Real':[0]
}
df1 = pd.DataFrame(data)



# Reading From Excel Files
df = pd.read_excel('c:/myData/PhD/code/output_1.xlsx')
#print(df.loc[df['sn']>0,['Attacker']])
arr = eval(df.to_json())

#Label the defence levels
defence_2 = 2
defence_1 = 1
defence_0 = 0

x_point = []
y_point_0 = []
y_point_1 = []
y_point_2 = []
y_point_Real=[]
success_0_count=0
success_1_count=0
success_2_count=0
success_real_count=0
for i in range(len(arr['Attacker'])):
    attacker = arr['Attacker'][str(i)]
    defenderReal = arr['Defender'][str(i)]
    
    #if (defenderReal>attacker):
     #   success_real=1
      #  success_real_count+=1
    
    #if defence_0==0:
     #   if(attacker <= defence_0):
      #      success_0 = 1
     #       success_0_count+=1
        
    #if defence_1==1:
     #   if(attacker <= 1):
      #      success_1 = 1
       #     success_1_count+=1
    k=i+1
    if (attacker<=0): success_0_count+=1
    if (attacker<=1): success_1_count+=1
    if (attacker<=2): success_2_count+=1
    if (attacker<=defenderReal): success_real_count+=1
    if (i%100==0):
        pamela_0=(success_0_count/k)*100
        pamela_1=(success_1_count/k)*100
        pamela_2=(success_2_count/k)*100
        pamela_Real=(success_real_count/k)*100

        # new_record = {'cycle': 0, 'level-0': 1, 'level-1': 2, 'level-2': 3, 'level-Real': 4}
        new_record = {'cycle': i, 'level-0': f'{pamela_0:.2f}', 'level-1': f'{pamela_1:.2f}', 'level-2': f'{pamela_2:.2f}', 'level-Real': f'{pamela_Real:.2f}'}
        #print(f'i = {i} and RE = {y_point_0}and RE = {y_point_1}and RE = {y_point_2}and RE = {y_point_Real}')
        # Append the new record to the DataFrame
        df1 = df1.append(new_record, ignore_index=True)
    #print(len(y_point_2), i, len(x_point))
    #End of insertion                  
    #    print(attacker,defenderReal,success_0_count,success_1_count,success_2_count,success_real_count)
    x_point.append(i)
for j in range(i+1):
    y_point_0.append(success_0_count/i*100)
    y_point_1.append(success_1_count/i*100)
    y_point_2.append(success_2_count/i*100)
    y_point_Real.append(success_real_count/i*100)

df1.to_excel(filename, index=False)
# Print the updated DataFrame
print(df) 
plt_x = np.array(x_point)
plt_y = np.array(y_point_0)
key0, = plt.plot(plt_x, plt_y, label ='Defence: Level-0')

#plt_x = np.array(x_point)
plt_y = np.array(y_point_1)
key1, = plt.plot(plt_x, plt_y, label ='Defence: Level-1')

plt_x = np.array(x_point)
plt_y = np.array(y_point_2)
key2, = plt.plot(plt_x, plt_y, label ='Defence: Level-2')

plt_x = np.array(x_point)
plt_y = np.array(y_point_Real)
keyReal, = plt.plot(plt_x, plt_y, label ='SimDefence: Level-Real')

# Set Axes
plt.xlim(left=0)

leg = plt.legend(loc='upper center')
plt.xlabel('Time (cycle)')
plt.ylabel('Defence Sucess Rate (%)')
plt.title('Success Rate against Times')
plt.show()
print(success_0_count,success_1_count,success_2_count,success_real_count)
print()

Youez - 2016 - github.com/yon3zu
LinuXploit