-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
For viewing results, would be good to save the predictions to a csv/geojson file with 1 row per prediction instead of aggregated at the article level.
Code for doing this using current csv:
import pandas as pd
from ast import literal_eval
import geopandas as gpd
from shapely import Point
preds = pd.read_csv("./UK_France_test_sample_pretrained-perfectmatch-reldisamb-predictpub-combined-nomicro.csv")
preds["predictions"] = preds["predictions"].apply(literal_eval) # apply literal_eval to ensure predictions column is interpreted as a list
predictions = preds["predictions"].tolist() # get predictions column
predictions = [
pred for prediction in predictions for pred in prediction
] # flatten list
df = pd.DataFrame(predictions)
df["predicted_coordinates"] = df["predicted_coordinates"].apply(Point) # convert coords to shapely point
gdf = gpd.GeoDataFrame(df, geometry="predicted_coordinates") # create geodataframe
gdf.to_file("UK_France_test_sample_pretrained-perfectmatch-reldisamb-predictpub-combined-nomicro.geojson", driver="GeoJSON") # save to geojson
If you already have the predictions list, start from flattening.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels