Skip to content

Instantly share code, notes, and snippets.

View yashprakash13's full-sized avatar
📱

Yash Prakash yashprakash13

📱
  • DNEG
  • Toronto, CA
  • 23:28 (UTC -04:00)
View GitHub Profile
@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 {
@yashprakash13
yashprakash13 / .gitignore
Created December 19, 2020 15:24 — forked from GhostofGoes/.gitignore
Basic .gitignore template for Python projects
# Editors
.vscode/
.idea/
# Vagrant
.vagrant/
# Mac/OSX
.DS_Store
@yashprakash13
yashprakash13 / app.py
Created April 4, 2021 17:26
FastApi example
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()
@yashprakash13
yashprakash13 / helloworld.py
Created May 30, 2021 17:00
Gist starter code to set up Docker Development Environment in VSCode.
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
import requests
import pandas as pd
from prefect import task, Flow
import json
@task
def extract(url_from):
response = requests.get(url_from)
@yashprakash13
yashprakash13 / df.py
Created December 26, 2021 15:55
Sklearn Pipeline
df = pd.read_csv('data.csv')
df.head()
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
# 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')),
# 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=[
# 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),
])