This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from pydantic import ValidationError | |
from some.path.features import AnimalFeatures, FeatureIsNoneError | |
from some.other.path.models import ML_MODEL | |
from some.logger import log | |
def create_features() -> np.ndarray: | |
# instantiate the features container |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing as T | |
import pandas as pd | |
import numpy as np | |
def create_features_container_from_dataframe( | |
df: pd.DataFrame, | |
class_name: str = "Features", | |
) -> str: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing as T | |
import numpy as np | |
from pydantic import BaseModel | |
from pydantic.types import conint, confloat | |
class FeatureIsNoneError(Exception): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Dict | |
import pandas as pd | |
from sklearn.metrics import euclidean_distances | |
def get_personalized_hotel_recommendations(df: pd.DataFrame, user_features: Dict) -> pd.DataFrame: | |
# features used to compute the similarity | |
features = ['distance', 'avg_rate', 'star_rating', 'user_rating'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from sklearn.metrics import euclidean_distances | |
from sklearn.preprocessing import StandardScaler | |
def get_hotel_recommendations(df: pd.DataFrame, anchor_id: int) -> pd.DataFrame: | |
# features used to compute the similarity | |
features = ['lat', 'lng', 'avg_rate', 'star_rating', 'user_rating'] | |
# create the features - make the anchor be the first row in the dataframe |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.