stc_unicef_cpi.utils package
Submodules
stc_unicef_cpi.utils.constants module
stc_unicef_cpi.utils.general module
- stc_unicef_cpi.utils.general.create_folder(dir)
Create folder :param dir: directory :type dir: str
- stc_unicef_cpi.utils.general.download(url, filename, params=None)
- stc_unicef_cpi.utils.general.download_file(url, name)
Download a file from an specific url
- Parameters
url – URL where the specific object is placed
name – name of output file
- stc_unicef_cpi.utils.general.download_unzip(url, name)
- stc_unicef_cpi.utils.general.get_facebook_credentials(creds_file)
Get credentials for accessing FB API from the credentials file
- stc_unicef_cpi.utils.general.get_open_cell_credentials(creds_file)
Get credentials for accessing Open Cell Id from the credentials file
- stc_unicef_cpi.utils.general.prepend(list, str)
Prepend string to elements in list
- stc_unicef_cpi.utils.general.read_csv_gzip(args, colnames=['radio', 'mcc', 'mnc', 'lac', 'cid', 'range', 'long', 'lat', 'sample', 'changeable_1', 'changeable_0', 'created', 'updated', 'avg_signal'])
- stc_unicef_cpi.utils.general.read_yaml_file(yaml_file)
Load yaml configurations
- stc_unicef_cpi.utils.general.timing(f)
- stc_unicef_cpi.utils.general.unzip_file(name)
Unzip file :param name: name or path of file to unzip :type name: str
stc_unicef_cpi.utils.geospatial module
- stc_unicef_cpi.utils.geospatial.aggregate_hexagon(df, col_to_agg, name_agg, type)
- stc_unicef_cpi.utils.geospatial.create_geometry(data, lat, long)
Create geometry column from longitude (x) and latitude (y) columns :param data: dataset :type data: dataframe :param lat: name of column containing the longitude of a point :type lat: string :param long: name of column containing the longitude of a point :type long: string :return: data :rtype: datafrane with geometry column
- stc_unicef_cpi.utils.geospatial.format_polygons(poly)
Retrive type of polygon and convert to list
- stc_unicef_cpi.utils.geospatial.get_area_polygon(polygon, crs='WGS84')
Get area of a polygon on earth in km squared :param polygon: Polygon :type polygon: Polygon
- stc_unicef_cpi.utils.geospatial.get_hex_centroid(data, hex_code='hex_code')
Get centroid of hexagon :param data: dataset :type data: dataframe :param hex_code: name of column containing the hexagon code :type hex_code: string :return: coords :rtype: list of tuples
- stc_unicef_cpi.utils.geospatial.get_hex_code(df, lat, long, res)
- stc_unicef_cpi.utils.geospatial.get_hex_radius(res)
Get radius according to h3 resolution :param res: resolution :type res: int :return: radius corresponding to the resolution :rtype: float
- stc_unicef_cpi.utils.geospatial.get_hexes_for_ctry(ctry_name='Nigeria', res=7)
Get array of all hex codes for specified country :param ctry_name: _description_, defaults to ‘Nigeria’ :type ctry_name: str, optional :param level: _description_, defaults to 7 :type level: int, optional
- stc_unicef_cpi.utils.geospatial.get_lat_long(data, geo_col)
Get latitude and longitude points from a given geometry column :param data: dataset :type data: dataframe :param geo_col: name of column containing the geometry :type geo_col: string :return: dataset :rtype: dataframe with latitude and longitude columns
- stc_unicef_cpi.utils.geospatial.get_new_nbrs_at_k(hexes, k)
Given set of hexes, return set of new neighbors at k distance Useful for expanding country hex sets
- Parameters
hexes (_type_) – _description_
k (_type_) – _description_
- stc_unicef_cpi.utils.geospatial.get_poly_boundary(df, hex_code)
- stc_unicef_cpi.utils.geospatial.get_shape_for_ctry(ctry_name)
- stc_unicef_cpi.utils.geospatial.hexes_poly(poly, res)
Get dataframe with hexagons belonging to a polygon :param poly: polygon :type poly: polygon :param res: resolution :type res: int :raises IOError: _description_ :return: _description_ :rtype: _type_
stc_unicef_cpi.utils.mlflow_utils module
- stc_unicef_cpi.utils.mlflow_utils.fetch_logged_data(run_id)
Fetch params, metrics, tags, and artifacts in the specified run
- stc_unicef_cpi.utils.mlflow_utils.yield_artifacts(run_id, path=None)
Yield all artifacts in the specified run
stc_unicef_cpi.utils.scoring module
- stc_unicef_cpi.utils.scoring.mae(true, pred)
Calculate mean absolute error
- Parameters
true (_type_) – _description_
pred (_type_) – _description_
- Returns
_description_
- Return type
_type_