Skip to content

Instantly share code, notes, and snippets.

Shivendra Agrawal ShivendraAgrawal

Block or report user

Report or block ShivendraAgrawal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ShivendraAgrawal
ShivendraAgrawal / single-layer-nn.py
Created Aug 16, 2016
A single layer neural network script using numpy performed on iris set from scikit-learn
View single-layer-nn.py
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()
@ShivendraAgrawal
ShivendraAgrawal / Scikit-Learn-snippets.py
Last active Dec 12, 2016
Scikit-Learn sample snippets for copy-paste
View Scikit-Learn-snippets.py
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 / 0_reuse_code.js
Created Feb 15, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View whiteboard.sh
#!/bin/bash
convert "$1" \
-morphology Convolve DoG:15,100,0 \
-negate -normalize -blur 0x1 \
-channel RGB -level 60%,91%,0.1\ -colorspace Gray \
"$2"
View greenboard.sh
#!/bin/bash
convert "$1" \
-morphology EdgeIn Octagon \
-negate -normalize -blur 0x2 \
-channel RGB -level 50%,81%,0.1 \ -colorspace Gray \
"$2"
View automatic_select.m
function [] = automatic_select()
count = 0;
imageFiles = dir('*.jpg');
nFiles = length(imageFiles);
white_counts = zeros(nFiles);
for i = 1 : nFiles
count = count + 1;
currentFileName = imageFiles(i).name;
View shivendra.m
function [n2] = shivendra( image )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
rgb = imread(image) ;
gray = rgb2gray(rgb) ;
%(gray,'gray.jpg');
%imwrite(gray>180,'undilated.jpg');
%filteredgray = medfilt2(gray,[7 7]);
View server.py
import os
from os import listdir
from os.path import isfile, join
# We'll render HTML templates and access data sent by POST
# using the request object from flask. Redirect and url_for
# will be used to redirect the user once the upload is done
# and send_from_directory will help us to send/show on the
# browser the file that the user just uploaded
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from werkzeug import secure_filename
View index2.html
!DOCTYPE HTML>
<html>
<body>
{% for v in onlyfiles %}
<img src="{{ url_for('static', filename = v) }}" width="1050" height="300">
{% endfor %}
</body>
</html>
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container">
<div class="header">
<h3 class="text-muted">How To Upload a File</h3>
You can’t perform that action at this time.