agroimpacts / learner

Machine learning component of the active learning platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change a nicer key name in config and object names in code for prediction

LLeiSong opened this issue · comments

Leave them as old for now. Need to update for next production season.

  1. catalog_prefix_fix = params['image_catalog_fix']

    catalog_prefix_predict = params['image_catalog_predict']

And
2. All the fix here:

image_catalog_fix = spark.read \
.option('inferScheme', True) \
.option('header', True) \
.csv('s3n://{}/{}'.format(s3_bucket, catalog_prefix_fix)) \
.repartition('col', 'row')
all_image_uris_fix = image_catalog_fix \
.filter(image_catalog_fix['season'] == 'GS') \
.alias('gs') \
.join(image_catalog_fix.filter(image_catalog_fix['season'] == 'OS').alias('os'),
(col('gs.col') == col('os.col')) & (col('gs.row') == col('os.row'))) \
.select(col('gs.col'), col('gs.row'), col('gs.uri').alias('GS'), col('os.uri').alias('OS'))
#recollect all pixels for all testing images
compreh_names = f_pool.join(qs_in, ['name', 'col', 'row', 'name_col_row'], 'outer')
features_compreh = gather_data(all_image_uris_fix,
compreh_names,
master_metadata,
feature_names,
s3_bucket)
fitted_compreh = model.transform(features_compreh)\
.select('spatial_key', 'column_index', 'row_index', 'probability', 'prediction')
grouped_compreh = fitted_compreh.groupBy('spatial_key')
# added to test sampling
assembled = grouped_compreh.agg(
assembleTile('column_index',
'row_index',
secondelement('probability'),
master_layout.tileLayout.tileCols,
master_layout.tileLayout.tileRows,
'float32'
).alias('probability')
)
layer = gps.TiledRasterLayer.from_rasterframe(assembled.asRF())