Skip to content

Commit

Permalink
update dataset file
Browse files Browse the repository at this point in the history
  • Loading branch information
MsPixels committed Sep 8, 2024
1 parent 9155e63 commit 2d4b110
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 3 additions & 3 deletions data/raw.dvc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
outs:
- md5: 7ba2a5b698999a9bfa635252b5090ff7.dir
size: 446381456
nfiles: 406
- md5: 09571fac13b659414b7cafdcb1abc38d.dir
size: 446724276
nfiles: 408
path: raw
hash: md5
34 changes: 34 additions & 0 deletions datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,41 @@ def load_labels(self) -> pd.DataFrame:
df[START], df[END] = date(2019, 1, 1), date(2020, 12, 31)
df[SUBSET] = train_val_test_split(df.index, 0.3, 0.3)
return df



class UgandaNorthCEO2020(LabeledDataset):
def load_labels(self) -> pd.DataFrame:
raw_folder = raw_dir / "Uganda_North_2020"
df1 = pd.read_csv(
raw_folder
/ "ceo-UNHCR-North-Uganda-Feb-2020---Feb-2021-(Set-1)-sample-data-2024-09-07.csv"
)
df2 = pd.read_csv(
raw_folder
/ "ceo-UNHCR-North-Uganda-Feb-2020---Feb-2021-(Set-2)-sample-data-2024-09-07.csv"
)
df = pd.concat([df1, df2])

# Discard rows with no label
df = df[~df["Does this pixel contain active cropland?"].isna()].copy()
df[CLASS_PROB] = df["Does this pixel contain active cropland?"] == "Crop"
df[CLASS_PROB] = df[CLASS_PROB].astype(int)
df["num_labelers"] = 1
df = df.groupby([LON, LAT], as_index=False, sort=False).agg(
{
CLASS_PROB: "mean",
"num_labelers": "sum",
"plotid": join_unique,
"sampleid": join_unique,
"email": join_unique,
}
)
df[START], df[END] = date(2020, 1, 1), date(2021, 12, 31)
df[SUBSET] = train_val_test_split(df.index, 0.3, 0.3)
return df


class UgandaNorthCorLabel2022(LabeledDataset):
def load_labels(self) -> pd.DataFrame:
raw_folder = raw_dir / "Uganda_North_2022_GEE_labels"
Expand Down Expand Up @@ -1538,6 +1571,7 @@ def load_labels(self) -> pd.DataFrame:
TanzaniaCropArea2019(),
FranceCropArea2020(),
Uganda_NorthCEO2016(),
UgandaNorthCEO2020(),
]

if __name__ == "__main__":
Expand Down

0 comments on commit 2d4b110

Please sign in to comment.