Update app.py
Browse files
app.py
CHANGED
|
@@ -123,11 +123,7 @@ class Stats:
|
|
| 123 |
vectors = {f'{row["yearID"]}{row["playerID"]}': self.transform(row) for _, row in self.stats.iterrows()}
|
| 124 |
data = {f'{row["yearID"]}{row["playerID"]}': dict(row) for _, row in self.stats.iterrows()}
|
| 125 |
|
| 126 |
-
embeddings = Embeddings(
|
| 127 |
-
{
|
| 128 |
-
"transform": Stats.transform
|
| 129 |
-
}
|
| 130 |
-
)
|
| 131 |
|
| 132 |
embeddings.index((uid, vectors[uid], None) for uid in vectors)
|
| 133 |
|
|
@@ -254,9 +250,9 @@ class Batting(Stats):
|
|
| 254 |
|
| 255 |
def load(self):
|
| 256 |
# Retrieve raw data
|
| 257 |
-
players = pd.read_csv("https://hf.co/datasets/neuml/
|
| 258 |
-
batting = pd.read_csv("https://hf.co/datasets/neuml/
|
| 259 |
-
fielding = pd.read_csv("https://hf.co/datasets/neuml/
|
| 260 |
|
| 261 |
# Merge player data in
|
| 262 |
batting = pd.merge(players, batting, how="inner", on=["playerID"])
|
|
@@ -388,8 +384,8 @@ class Pitching(Stats):
|
|
| 388 |
|
| 389 |
def load(self):
|
| 390 |
# Retrieve raw data
|
| 391 |
-
players = pd.read_csv("https://hf.co/datasets/neuml/
|
| 392 |
-
pitching = pd.read_csv("https://hf.co/datasets/neuml/
|
| 393 |
|
| 394 |
# Merge player data in
|
| 395 |
pitching = pd.merge(players, pitching, how="inner", on=["playerID"])
|
|
@@ -439,7 +435,7 @@ class Application:
|
|
| 439 |
st.markdown(
|
| 440 |
"""
|
| 441 |
This application finds the best matching historical players using vector search with [txtai](https://github.com/neuml/txtai).
|
| 442 |
-
Raw data is from the [Baseball
|
| 443 |
article](https://medium.com/neuml/explore-baseball-history-with-vector-search-5778d98d6846) for more details.
|
| 444 |
"""
|
| 445 |
)
|
|
|
|
| 123 |
vectors = {f'{row["yearID"]}{row["playerID"]}': self.transform(row) for _, row in self.stats.iterrows()}
|
| 124 |
data = {f'{row["yearID"]}{row["playerID"]}': dict(row) for _, row in self.stats.iterrows()}
|
| 125 |
|
| 126 |
+
embeddings = Embeddings({"transform": Stats.transform})
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
embeddings.index((uid, vectors[uid], None) for uid in vectors)
|
| 129 |
|
|
|
|
| 250 |
|
| 251 |
def load(self):
|
| 252 |
# Retrieve raw data
|
| 253 |
+
players = pd.read_csv("https://hf.co/datasets/neuml/baseballdata/resolve/main/People.csv")
|
| 254 |
+
batting = pd.read_csv("https://hf.co/datasets/neuml/baseballdata/resolve/main/Batting.csv")
|
| 255 |
+
fielding = pd.read_csv("https://hf.co/datasets/neuml/baseballdata/resolve/main/Fielding.csv")
|
| 256 |
|
| 257 |
# Merge player data in
|
| 258 |
batting = pd.merge(players, batting, how="inner", on=["playerID"])
|
|
|
|
| 384 |
|
| 385 |
def load(self):
|
| 386 |
# Retrieve raw data
|
| 387 |
+
players = pd.read_csv("https://hf.co/datasets/neuml/baseballdata/resolve/main/People.csv")
|
| 388 |
+
pitching = pd.read_csv("https://hf.co/datasets/neuml/baseballdata/resolve/main/Pitching.csv")
|
| 389 |
|
| 390 |
# Merge player data in
|
| 391 |
pitching = pd.merge(players, pitching, how="inner", on=["playerID"])
|
|
|
|
| 435 |
st.markdown(
|
| 436 |
"""
|
| 437 |
This application finds the best matching historical players using vector search with [txtai](https://github.com/neuml/txtai).
|
| 438 |
+
Raw data is from the [Lahman Baseball Database](https://sabr.org/lahman-database/). Read [this
|
| 439 |
article](https://medium.com/neuml/explore-baseball-history-with-vector-search-5778d98d6846) for more details.
|
| 440 |
"""
|
| 441 |
)
|