Skip to content

Instantly share code, notes, and snippets.

View neerajvashistha's full-sized avatar
🏠
Working from home

Neeraj Vashistha neerajvashistha

🏠
Working from home
View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression, RANSACRegressor
# For reproducibility
np.random.seed(1000)
nb_samples = 200
import knn_final
#do copy knn_final before running
if __name__ == '__main__':
from sklearn import datasets
iris = datasets.load_iris()
print(iris["data"])
predictors = iris.data[:,0:2]
outcomes = iris.target
plt.plot(predictors[outcomes==0][:,0],predictors[outcomes==0][:,1],"ro")
plt.plot(predictors[outcomes==1][:,0],predictors[outcomes==1][:,1],"go")
import numpy as np
def distance(p1,p2):
""" return distance between pony p1 and p2 """
return np.sqrt(np.sum(np.power(p2-p1,2)))
def majority_vote(votes):
"""
return winner for a list of votes
or just return scipy.stats.mode(votes)
import numpy as np
def distance(p1,p2):
""" return distance between pony p1 and p2 """
return np.sqrt(np.sum(np.power(p2-p1,2)))
def majority_vote(votes):
"""
return winner for a list of votes
or just return scipy.stats.mode(votes)
import string
alphabet = ' '+ string.ascii_lowercase
count = 0
positions=dict()
for a in alphabet:
positions[a] = count
count = count + 1
def shift_encode(message,key):
encoding_list = []
absl-py==0.7.1
astor==0.8.0
atomicwrites==1.3.0
attrs==19.3.0
backcall==0.1.0
beautifulsoup4==4.8.1
bleach==3.1.0
blis==0.4.1
boto==2.49.0
boto3==1.10.0
# Common Internet File System utilities
# Wed Aug 8 12:34:05 IST 2018
sudo apt-get install cifs-utils
# Modern music player and library organiser inspired by Amarok 1.4
# Tue May 22 13:21:25 IST 2018
sudo apt-get install clementine
# cross-platform, open-source make system
# Sun Feb 18 17:55:21 IST 2018
from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression
from sklearn import metrics
from sklearn.ensemble import RandomForestClassifier
model = LogisticRegression()
rfe = RFE(model,12)
rfe = rfe.fit(emp_train[x],emp_train[y])
print(rfe.support_)
# coding: utf-8
# In[29]:
import pandas as pd
import numpy as np
@neerajvashistha
neerajvashistha / tictactoe.py
Created September 13, 2018 12:55
TicTacToe just a fun game when i am bored
import numpy as np
import random
import time
import matplotlib.pyplot as plt
def create_board():
return np.zeros((3,3))
board = create_board()