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 train_model(X_train, y_train, X_test, y_test): | |
model = Sequential() | |
model.add(Conv2D(kernel_size=(3, 3), filters=32, | |
input_shape=input_shape)) | |
model.add(Activation('relu')) | |
model.add(Conv2D(kernel_size=(3, 3), filters=32)) | |
model.add(Activation('relu')) | |
model.add(MaxPooling2D(2, 2)) |
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 joblib | |
import re | |
from sklearn.neural_network import MLPClassifier | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from fastapi import FastAPI | |
app = FastAPI() | |
model = joblib.load('spam_classifier.joblib') |
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 | |
# Read the Data | |
data = pd.read_csv('./data/spam_data.csv') | |
# Text Preprocessing | |
import re # regex library |
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 joblib | |
import re | |
from sklearn.neural_network import MLPClassifier | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
import streamlit as st | |
from lime.lime_text import LimeTextExplainer | |
import streamlit.components.v1 as components | |
st.write("# Spam Detection Engine") |
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 | |
# Read the Data | |
data = pd.read_csv('./data/spam_data.csv') | |
# Text Preprocessing | |
import re # regex library |
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 collections import defaultdict | |
from scipy.spatial.distance import cdist | |
import difflib | |
number_cols = ['valence', 'year', 'acousticness', 'danceability', 'duration_ms', 'energy', 'explicit', | |
'instrumentalness', 'key', 'liveness', 'loudness', 'mode', 'popularity', 'speechiness', 'tempo'] | |
def get_song_data(song, spotify_data): | |
""" |
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 spotipy.oauth2 import SpotifyClientCredentials | |
from collections import defaultdict | |
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id=os.environ["SPOTIFY_CLIENT_ID"], | |
client_secret=os.environ["SPOTIFY_CLIENT_SECRET"])) | |
def find_song(name, year): | |
""" |
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
""" | |
Utility functions for generating movie recommendations using sequence models. | |
""" | |
import difflib | |
def get_movie_id(movie_title, metadata): | |
""" | |
Gets the movie id for a movie title | |
""" | |
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
""" | |
Utility functions for generating movie recommendations using matrix factorization models | |
""" | |
def get_metadata(movie_id, metadata): | |
""" | |
Retrieves the metadata for a movie given the movie ID | |
""" | |
movie_data = metadata[metadata['movieId'] == movie_id] | |
return movie_data[['original_title', 'release_date', 'genres']].to_dict(orient='records') |
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 difflib | |
import random | |
def get_book_id(book_title, metadata): | |
""" | |
Gets the book ID for a book title based on the closest match in the metadata dataframe. | |
""" | |
existing_titles = list(metadata['title'].values) |
NewerOlder