Skip to content

Instantly share code, notes, and snippets.

@ashokasr
ashokasr / Imputing.py
Created December 11, 2017 08:52
Imputing the variable based on pivot variables
impute=titanic.pivot_table(values=['Age'],index=['Sex','Survived'],aggfunc=np.mean)
impute
for i in range(len(titanic)):
if np.isnan(titanic.Age[i]):
if (titanic.Sex[i]=='female') & (titanic.Survived[i]==0):
titanic.Age[i]=25.04
for i in range(len(titanic)):
if np.isnan(titanic.Age[i]):
if (titanic.Sex[i]=='female') & (titanic.Survived[i]==1):
titanic.Age[i]=28.84
@ashokasr
ashokasr / CNN.py
Created December 11, 2017 05:10
Convolution Neural Network in Python
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 10 22:55:00 2017
@author: Ashok
"""
# Importing the Keras libraries and packages
from keras.models import Sequential
from keras.layers import Convolution2D
@ashokasr
ashokasr / ANN.py
Created December 10, 2017 14:51
Artificial Neural Network in Python using tenserflow,Keras
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('Churn_Modelling.csv')
# Encoding categorical data
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder_X_1 = LabelEncoder()