kahramankostas / IoTDevIDv2

A Behavior-Based Device Identification Method for the IoT
MIT License
44 stars 12 forks source link

02.2 Comparison of isolated and CV methods.ipynb , ML_isolated(train,test,output_csv,features,step,flexible,i) give me error ValueError: could not convert string to float: 'b' #6

Open AhmedmostafaElabdli1 opened 5 months ago

AhmedmostafaElabdli1 commented 5 months ago

image

and i found in altro train IOTDevID csv data image

kahramankostas commented 5 months ago

Thank you very much for bringing attention to this issue. As you mentioned, the error stems from the presence of "b" values in the CSV files. To address this, we have developed a small script that replaces the "b" values with 0. You can locate this script in the root of the repository under the name b-error-fixer.ipynb. We greatly appreciate your contribution and assistance in resolving this issue. Thank you once again.


#!/usr/bin/env python
# coding: utf-8

# In[8]:

import os
import pandas as pd
from tqdm import tqdm
import warnings
warnings.filterwarnings('ignore')
def find_the_way(path,file_format):
    files_add = []
    # r=root, d=directories, f = files
    for r, d, f in os.walk(path):
        for file in f:
            if file_format in file:
                files_add.append(os.path.join(r, file))  
    return files_add
files_add=find_the_way('./CSVS','.csv')
files_add

# In[9]:

for i in  tqdm(files_add):
    df=pd.read_csv(i)
    df.replace('b', 0, inplace=True)
    df.to_csv(i,index=False)
    #print(i)```