Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In put path and directory
#1
I have a question about the following python 3 code.

def _create_df(path, directory):
    """
    Creates a df (with shuffled entries)
    with two columns: file name and label (0: normal or 1: pneumonia)
    """

files1 = glob.glob (path + directory + "/NORMAL/*.jpeg")
files2 = glob.glob (path + directory + "/PNEUMONIA/*.jpeg")
# creating the train set
df_n = pd.DataFrame()
df_p = pd.DataFrame()
df_n['name'] = [x for x in files1]
df_n['outcome'] = 0
df_p['name'] = [x for x in files2]
df_p['outcome'] = 1.
df = pd.concat([df_n, df_p], axis = 0, ignore_index = True)
df = shuffle(df) # shuffle the dataset

return df

def create_x_and_y(self):
    X = np.array([img_preprocess(p) for p in self.train_df.name.values])
    y = train_df.outcome.values

return X, y
The question concerns the two inputs, path and directory. I assumed until now that a path is made-up of directories.

I also assume that when the actual values are put in they must be put in quotes and directories separated by backslashes.

Any help appreciated. Thanks in advance.

The paper that I am referring to can be found at this link.

https://medium.com/analytics-vidhya/how-...5b0c36e66e

Respectfully,

LZ
Reply
#2
Please fix indentation
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  working directory if using windows path-variable chitarup 2 743 Nov-28-2023, 11:36 PM
Last Post: chitarup
  create a default path with idle to a specific directory greybill 0 883 Apr-23-2023, 04:32 AM
Last Post: greybill
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,225 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  How do I set the path to my module one directory below my python 3.7.3 program? deac33 1 2,031 Jul-30-2019, 04:13 AM
Last Post: Larz60+
  Directory path gahhon 3 2,968 Mar-03-2019, 11:39 PM
Last Post: DeaD_EyE
  Directory path EOF Graham 8 4,701 Nov-28-2018, 10:13 PM
Last Post: Graham
  .pth file does not show up in sys.path when configuring path. arjunsingh2908 2 5,781 Jul-03-2018, 11:16 AM
Last Post: arjunsingh2908

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020