This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[29]: | |
import pandas as pd | |
import numpy as np | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import random | |
import time | |
import matplotlib.pyplot as plt | |
def create_board(): | |
return np.zeros((3,3)) | |
board = create_board() |