mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 18:23:06 +02:00
feat: add seed to randomizing anime
This commit is contained in:
parent
ffd805450d
commit
e0b160f071
3
.vscode/extensions.json
vendored
Normal file
3
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["james-yu.latex-workshop"]
|
||||||
|
}
|
||||||
@ -156,12 +156,12 @@ def preprocessing(rating_data, anime_contact_data, debug=False):
|
|||||||
return pivot_table
|
return pivot_table
|
||||||
|
|
||||||
|
|
||||||
def predict(prediction_model, pivot_table):
|
def predict(prediction_model, pivot_table, seed=42):
|
||||||
"""
|
"""
|
||||||
This will choose a random anime name and our prediction_model will predict similar anime.
|
This will choose a random anime name and our prediction_model will predict similar anime.
|
||||||
"""
|
"""
|
||||||
|
np.random.seed(seed)
|
||||||
random_anime = np.random.choice(pivot_table.shape[0])
|
random_anime = np.random.choice(pivot_table.shape[0])
|
||||||
|
|
||||||
query = pivot_table.iloc[random_anime, :].values.reshape(1, -1)
|
query = pivot_table.iloc[random_anime, :].values.reshape(1, -1)
|
||||||
distance, suggestions = prediction_model.kneighbors(query, n_neighbors=6)
|
distance, suggestions = prediction_model.kneighbors(query, n_neighbors=6)
|
||||||
random_anime_name = pivot_table.index[random_anime]
|
random_anime_name = pivot_table.index[random_anime]
|
||||||
Loading…
Reference in New Issue
Block a user