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 statsmodels.stats.outliers_influence import variance_inflation_factor | |
def get_vif(X, drop_cols = []): | |
X = X.drop(columns = drop_cols).dropna() | |
vif_data = pd.DataFrame() | |
vif_data['feature'] = X.columns | |
vif_data['VIF'] = [variance_inflation_factor(X.values, i) for i in range(len(X.columns))] | |
return vif_data.sort_values(by = 'VIF').reset_index(drop=True) |
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
x = np.arange(0,10) | |
y = [10,8,7,8,6,5,4,4,3,13] | |
fig, ax = plt.subplots(figsize = (15,10)) | |
line, = ax.plot(x, y, 'bo--', color='k') | |
plt.grid() | |
def update(num, x, y, line): | |
line.set_data(x[:num+1], y[:num+1]) | |
line.set_animated(True) | |
color = 'black' |
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
# Send notifications to a slack channel through slack webhooks. | |
import requests | |
import json | |
webhook = '' # Slack channel webhook. | |
def notify_slack(message): | |
""" | |
Send a string to slack channel. | |
message: str |
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
""" | |
Lambda function for starting an already set EC2 instance and ssh-ing into it using Paramiko library. | |
Paramiko is installed on lambda using lambda layers. | |
""" | |
import json | |
import paramiko | |
import boto3 | |
region = '' |
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
""" | |
Lambda function to switch on/off an ec2 instance. | |
Event can be passed like: | |
{ | |
"action" : "list" -> to list all the instances. | |
: "start" -> to start a already set instance. | |
: "stop" -> to stop a alreadt set instance. | |
} | |
""" |