Skip to content

Commit

Permalink
add arg for geo function and fix readme url (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
yinsn authored Jul 20, 2022
1 parent 8c2a323 commit ba7a17a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Python](https://img.shields.io/badge/python-3.6%7C3.7%7C3.8%7C3.9-red?logo=Python&logoColor=white)](https://www.python.org)
[![PyPI](https://img.shields.io/pypi/v/rsdiv?color=green)](https://pypi.org/project/rsdiv/)
[![GitHub](https://img.shields.io/github/license/yuanlonghao/reranking?color=blue)](https://github.com/smartnews/rsdiv)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/smartnews/rsdiv)

**rsdiv** is a Python package for recommender systems to provide the measurements and improvements for the diversity of results.

Expand Down Expand Up @@ -142,7 +142,7 @@ metrics.get_lorenz_curve(ratings['movieId'])
>>> df = geo.read_source()
>>> rng = np.random.RandomState(42)
>>> df['random_values'] = rng.rand(len(df))
>>> geo.draw_geo_graph(df, 'random_values')
>>> geo.draw_geo_graph(df, 'random_values', 'name')
```

![GeoEncoder](pics/random_values.png)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

setup(
name="rsdiv",
version="0.2.1",
version="0.2.2",
author="Yin Cheng",
author_email="[email protected]",
long_description=LONG_DESCRIPTION,
Expand Down
5 changes: 4 additions & 1 deletion src/rsdiv/encoding/geo_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,17 @@ def encoding_series(self, series: pd.Series) -> pd.Series:
encodings = pd.Series(series.apply(lambda x: self.encoding_single(x)))
return encodings

def draw_geo_graph(self, dataframe: pd.DataFrame, source_name: str) -> None:
def draw_geo_graph(
self, dataframe: pd.DataFrame, source_name: str, hover_name: str
) -> None:
max_value: float = np.ceil(dataframe[source_name].max())
min_value: float = np.floor(dataframe[source_name].min())
fig = px.choropleth(
dataframe,
geojson=self.encode_source,
locations="index",
color=source_name,
hover_name=hover_name,
color_continuous_scale="OrRd",
range_color=(min_value, max_value),
scope="usa",
Expand Down

0 comments on commit ba7a17a

Please sign in to comment.