import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # Step 1: Organize the data into a Pandas DataFrame data = { "Dataset": ["Car", "Car", "Car", "Car", "Car", "Car", "Car", "Car", "Car", "Statlog", "Statlog", "Statlog", "Statlog", "Statlog", "Statlog", "Statlog", "Statlog", "Statlog", "Page Block", "Page Block", "Page Block", "Page Block", "Page Block", "Page Block", "Page Block", "Page Block", "Page Block", "Contraceptive Prevalence Survey", "Contraceptive Prevalence Survey", "Contraceptive Prevalence Survey", "Contraceptive Prevalence Survey", "Contraceptive Prevalence Survey", "Contraceptive Prevalence Survey", "Contraceptive Prevalence Survey", "Contraceptive Prevalence Survey", "Contraceptive Prevalence Survey"], "Model": ["OVO", "WW", "BDT", "K-SVCR", "LSK-SVCR", "DCSVM", "RSSVM", "SRSSVM", "Our model", "OVO", "WW", "BDT", "K-SVCR", "LSK-SVCR", "DCSVM", "RSSVM", "SRSSVM", "Our model", "OVO", "WW", "BDT", "K-SVCR", "LSK-SVCR", "DCSVM", "RSSVM", "SRSSVM", "Our model", "OVO", "WW", "BDT", "K-SVCR", "LSK-SVCR", "DCSVM", "RSSVM", "SRSSVM", "Our model"], "Linear Kernel": [0.9327, 0.9486, 0.9611, 0.9819, 0.9895, 0.9901, 0.9921, 0.9901, 0.9996, 0.9546, 0.9521, 0.9589, 0.9744, 0.9924, 0.9843, 0.9837, 0.9831, 0.9913, 0.9231, 0.9312, 0.9386, 0.9611, 0.9676, 0.9717, 0.9814, 0.9795, 0.9906, 0.9427, 0.9294, 0.9413, 0.9451, 0.9743, 0.9816, 0.9804, 0.9869, 0.9947], "Polynomial Kernel": [0.9381, 0.9493, 0.9578, 0.9786, 0.9910, 0.9895, 0.9876, 0.9898, 0.9953, 0.9338, 0.9411, 0.9669, 0.9897, 0.9799, 0.9847, 0.9926, 0.9803, 1.0000, 0.9319, 0.9214, 0.9503, 0.9543, 0.9706, 0.9681, 0.9731, 0.9716, 0.9894, 0.9380, 0.9416, 0.9384, 0.9603, 0.9699, 0.9742, 0.9961, 0.9852, 0.9874], "RBF Kernel": [0.9443, 0.9519, 0.9674, 0.9831, 0.9951, 0.9874, 0.9889, 0.9976, 0.9901, 0.9419, 0.9499, 0.9704, 0.9775, 0.9820, 0.9913, 0.9909, 0.9924, 0.9991, 0.9394, 0.9297, 0.9441, 0.9615, 0.9724, 0.9698, 0.9746, 0.9702, 0.9839, 0.9489, 0.9306, 0.9512, 0.9698, 0.9753, 0.9789, 0.9826, 0.9905, 1.0000] } # Convert to DataFrame df = pd.DataFrame(data) # Step 2: Melt the DataFrame for easier plotting df_melted = df.melt(id_vars=["Dataset", "Model"], var_name="Kernel", value_name="Accuracy") # Step 3: Create a separate plot for each dataset datasets = df_melted["Dataset"].unique() # Define a consistent dash style for ALL models (adjust numbers for different patterns) dash_styles = { "OVO": (4, 2), "WW": (4, 2), "BDT": (4, 2), "K-SVCR": (4, 2), "LSK-SVCR": (4, 2), "DCSVM": (4, 2), "RSSVM": (4, 2), "SRSSVM": (4, 2), "Our model": (4, 2) } for dataset in datasets: plt.figure(figsize=(10, 6)) subset = df_melted[df_melted["Dataset"] == dataset] # Plot with custom dashes sns.lineplot( x="Kernel", y="Accuracy", hue="Model", style="Model", data=subset, markers=True, #dashes=dash_styles, # Enforce dashed lines palette="tab10", ci=None, linewidth=4, markersize=11 ) plt.title(f"Accuracy Comparison for {dataset}", fontsize=15) # , fontweight="bold" plt.xlabel("Kernel Type", fontsize=14) plt.ylabel("Accuracy", fontsize=14) plt.legend( title="Model", bbox_to_anchor=(1.05, 1), loc="upper left", framealpha=0.9 ) #plt.grid(True, linestyle='--', alpha=0.6) # Add grid for readability plt.tight_layout() plt.show()
An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in  on line 0. in /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
#1 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
#2 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/ErrorHandler.php(135): yii\web\ErrorHandler->renderException()
#3 [internal function]: yii\base\ErrorHandler->handleException()
#4 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in  on line 0. in /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
#1 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Application.php(656): yii\web\Response->send()
#2 /var/www/html/prof-homepages/vendor/faravaghi/yii2-filemanager/models/Files.php(696): yii\base\Application->end()
#3 /var/www/html/prof-homepages/vendor/faravaghi/yii2-filemanager/controllers/FilesController.php(484): faravaghi\filemanager\models\Files->getFile()
#4 [internal function]: faravaghi\filemanager\controllers\FilesController->actionGetFile()
#5 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#6 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams()
#7 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction()
#8 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction()
#9 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest()
#10 /var/www/html/prof-homepages/backend/web/index.php(16): yii\base\Application->run()
#11 {main}