This file contains hidden or 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 uvicorn | |
from typing import List | |
from pydantic import BaseModel | |
from fastapi import FastAPI | |
import tensorflow as tf | |
app = FastAPI() | |
model = tf.keras.models.load_model('../model/tf_keras_imdb') | |
class Reviews(BaseModel): |
This file contains hidden or 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 | |
data = pd.read_csv('winequality-red.csv', sep = ';') | |
data.head() | |
# Output: | |
fixed acidity volatile acidity citric acid residual sugar chlorides free sulfur dioxide total sulfur dioxide density pH sulphates alcohol quality | |
0 7.4 0.70 0.00 1.9 0.076 11.0 34.0 0.9978 3.51 0.56 9.4 5 | |
1 7.8 0.88 0.00 2.6 0.098 25.0 67.0 0.9968 3.20 0.68 9.8 5 | |
2 7.8 0.76 0.04 2.3 0.092 15.0 54.0 0.9970 3.26 0.65 9.8 5 | |
3 11.2 0.28 0.56 1.9 0.075 17.0 60.0 0.9980 3.16 0.58 9.8 6 |
This file contains hidden or 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 generate_co_occurrence_matrix(corpus): | |
vocab = set(corpus) | |
vocab = list(vocab) | |
vocab_index = {word: i for i, word in enumerate(vocab)} | |
# Create bigrams from all words in corpus | |
bi_grams = list(bigrams(corpus)) | |
# Frequency distribution of bigrams ((word1, word2), num_occurrences) |
This file contains hidden or 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 library | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
import pandas as pd | |
import numpy as np | |
# Text Corpus | |
corpus = ['This movie is very Scary and long', | |
'This movie is not scary and is slow', | |
'This movie is spooky and good' | |
] |
This file contains hidden or 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 sklearn.feature_extraction.text import CountVectorizer | |
corpus = ['This movie is very Scary and long', | |
'This movie is not scary and is slow', | |
'This movie is spooky and good' | |
] | |
# Defining the method to generate 1-gram BoW Tokens | |
vectorizer = CountVectorizer(lowercase = True, ngram_range = (1,1)) |