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
# Data wrangling | |
import pandas as pd | |
# Deep learning | |
import tensorflow as tf | |
import keras | |
# Import feature engineering functions | |
from utils import create_date_vars, distance_calculation, custom_transform |
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 | |
import numpy as np | |
import keras | |
# Defining the class for the batches creation | |
class DataGenerator(keras.utils.Sequence): | |
def __init__( | |
self, | |
csv_generator: pd.io.parsers.readers.TextFileReader, | |
n_batches: int, |
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
# Importing the feature engineering pipeline | |
from utils import ft_engineering_pipeline | |
# Data wrangling | |
import pandas as pd | |
# Memory tracking | |
from memory_profiler import profile | |
# Command line arguments |
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
# Deep learning | |
import tensorflow as tf | |
import keras | |
# Memory tracking | |
from memory_profiler import profile | |
@profile | |
def create_model( | |
input_size: int, |
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.preprocessing import OneHotEncoder | |
import numpy as np | |
# Defining the function for dummy creation | |
def create_dummy(df: pd.DataFrame, dummy_var_list: list) -> Tuple: | |
""" | |
Creates dummy variables for the variables in dummy_var_list | |
Returns a tuple of the following |
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 | |
import pandas as pd | |
# Defining the function for distance calculation | |
def distance_calculation(df: pd.DataFrame) -> pd.DataFrame: | |
""" | |
Calculates the distance between two points on the earth's surface. | |
The distance is in meters | |
""" |
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 datetime import datetime | |
import numpy as np | |
import re | |
# To datetime conversion | |
def to_datetime(x: str) -> datetime: | |
""" | |
Converts a string to a datetime object | |
An example of the string is 2010-02-02 17:24:55 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
def elastic_net_to_keras(alpha: float, l1_ratio: float): | |
""" | |
Converts ElasticNet parameters from sklearn to Keras regularizers. | |
Arguments | |
--------- | |
alpha: float | |
The regularization strength of the model. | |
l1_ratio: float | |
The l1 regularization ratio of the model. |
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
# Importing the package | |
import tensorflow as tf | |
class NMSE(tf.keras.losses.Loss): | |
def __init__(self): | |
super().__init__() | |
def call(self, y_true, y_pred): | |
# Calculating the mse; |
NewerOlder