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
| @Database(entities = [Word::class], version = 1, exportSchema = false) | |
| abstract class WordDatabase : RoomDatabase() { | |
| abstract fun wordDao() : WordDao | |
| companion object{ | |
| // For Singleton instantiation | |
| @Volatile private var INSTANCE: WordDatabase? = null | |
| fun getInstance(context: Context): WordDatabase { |
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
| # Editors | |
| .vscode/ | |
| .idea/ | |
| # Vagrant | |
| .vagrant/ | |
| # Mac/OSX | |
| .DS_Store |
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 fastapi import FastAPI | |
| from model import SentimentModel, SentimentQueryModel | |
| app = FastAPI() | |
| model = SentimentModel() | |
| @app.post('/predict') | |
| def predict(data: SentimentQueryModel): | |
| data = data.dict() |
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 fastapi import FastAPI | |
| app = FastAPI() | |
| @app.get("/") | |
| async def root(): | |
| return {"message": "Hello World"} |
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 requests | |
| import pandas as pd | |
| from prefect import task, Flow | |
| import json | |
| @task | |
| def extract(url_from): | |
| response = requests.get(url_from) |
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
| df = pd.read_csv('data.csv') | |
| df.head() |
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.model_selection import train_test_split | |
| X, y = df.drop('DEATH_EVENT', axis=1), df['DEATH_EVENT'] | |
| X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3) | |
| X_train.shape, X_test.shape, y_train.shape, y_test.shape |
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
| # COLUMN PIPELINE | |
| from sklearn.impute import SimpleImputer | |
| from sklearn.preprocessing import MinMaxScaler | |
| from sklearn.pipeline import Pipeline | |
| from sklearn.compose import ColumnTransformer | |
| › | |
| col_transformation_pipeline = Pipeline(steps=[ | |
| ('impute', SimpleImputer(strategy='mean')), |
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
| # MODEL Pipeline | |
| from sklearn.ensemble import RandomForestClassifier | |
| from sklearn.metrics import confusion_matrix, accuracy_score | |
| import matplotlib.pyplot as plt | |
| # random forest classifier | |
| rf_classifier = RandomForestClassifier(n_estimators = 11, criterion='entropy', random_state=0) | |
| rf_model_pipeline = Pipeline(steps=[ |
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
| # Do grid search | |
| from sklearn.model_selection import GridSearchCV | |
| rf_classifier = RandomForestClassifier(random_state=0) | |
| rf_model_pipeline = Pipeline(steps=[ | |
| ('preprocessing', columns_transformer), | |
| ('rf_model', rf_classifier), | |
| ]) |