Skip to content

Instantly share code, notes, and snippets.

View ShivendraAgrawal's full-sized avatar

Shivendra Agrawal ShivendraAgrawal

View GitHub Profile
@ShivendraAgrawal
ShivendraAgrawal / Scikit-Learn-snippets.py
Last active December 12, 2016 18:31
Scikit-Learn sample snippets for copy-paste
SOURCE http://blog.datadive.net/selecting-good-features-part-ii-linear-models-and-regularization/
# Correlation
import numpy as np
from scipy.stats import pearsonr
np.random.seed(0)
size = 300
x = np.random.normal(0, 1, size)
print "Lower noise", pearsonr(x, x + np.random.normal(0, 1, size))
print "Higher noise", pearsonr(x, x + np.random.normal(0, 10, size))
@ShivendraAgrawal
ShivendraAgrawal / single-layer-nn.py
Created August 16, 2016 11:30
A single layer neural network script using numpy performed on iris set from scikit-learn
import numpy as np
from sklearn import datasets
# sigmoid function
def activation(x,derivative=False):
if(derivative==True):
return x*(1-x)
return 1/(1+np.exp(-x))
iris = datasets.load_iris()