{{ message }}

Instantly share code, notes, and snippets.

# Aniruddha Bhandari aniruddha27

Created Mar 12, 2020
View matplotlib1.py
 import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.style.use('seaborn')
Created Mar 12, 2020
View Multicollinearity_VIF.py
 # Import library for VIF from statsmodels.stats.outliers_influence import variance_inflation_factor def calc_vif(X): # Calculating VIF vif = pd.DataFrame() vif["variables"] = X.columns vif["VIF"] = [variance_inflation_factor(X.values, i) for i in range(X.shape)]
Created Mar 12, 2020
View Multicollinearity_VIF_All.py
 X = df.iloc[:,:-1] calc_vif(X)
Created Mar 12, 2020
View Multicollinearity_VIF_Drop.py
 X = df.drop(['Age','Salary'],axis=1) calc_vif(X)
Created Mar 12, 2020
View Multicollinearity_VIF_Join.py
 df2 = df.copy() df2['Age_at_joining'] = df.apply(lambda x: x['Age'] - x['Years of service'],axis=1) X = df2.drop(['Age','Years of service','Salary'],axis=1) calc_vif(X)
Created Mar 12, 2020
View Linear regression model.py
 #import linear regression from sklearn.linear_model import LinearRegression #fit on training data lr=LinearRegression() lr.fit(X_train,y_train) #accuracy print('Training accuracy =',lr.score(X_train,y_train)) print('Testing accuracy =',lr.score(X_test,y_test))
Created Mar 12, 2020
View Ridge regression model.py
 #import ridge model from sklearn.linear_model import Ridge #fit on training data with regularization of 0.3 ridge = Ridge(alpha = 0.3) ridge.fit(X_train,y_train) #accuracy print('Train',ridge.score(X_train,y_train)) print('Test',ridge.score(X_test,y_test))
Created Mar 12, 2020
View Lasso regression model.py
 #import lasso from sklearn.linear_model import Lasso #fit on training dataset ls = Lasso(alpha=0.08) ls.fit(X_train, y_train) #accuracy print('Training score =', ls.score(X_train, y_train)) print('Testing score=', ls.score(X_test, y_test))
Last active Mar 12, 2020
View Matplotlib_meal_dataframe.py