This file contains 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
# Check file sizes | |
sudo du -h --max-depth=1 | sort -hr | head -n 10 | |
df -h | |
###### MOUNTING | |
https://learn.microsoft.com/en-us/azure/virtual-machines/linux/attach-disk-portal?tabs=ubuntu | |
# Mount disk |
This file contains 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
using CSV | |
using DataFrames | |
using Statistics | |
data = CSV.read("./iris_data.txt",header=false) | |
## no more head | |
first(data,5) | |
# renaming column header |
This file contains 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
knn <- function(new,df,k){ | |
dist_df <- data.frame() | |
for (i in 1:nrow(df)){ | |
distance <- 0 | |
# calculate distance | |
for (j in 1:length(new)){ | |
distance <- distance + (new[j] - df[i,j])^2 | |
} | |
This file contains 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 bs4 | |
def extract_reuters_news(path_file): | |
file = open(path_file , 'r').read() | |
soup = bs4.BeautifulSoup(path_file) | |
all_bodies = [el.text for el in soup.find_all('body')] | |
return all_bodies | |
path = './reuters001.html' | |
reuters = extract_reuters_news(path) |
This file contains 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 numpy import linalg | |
def return_eig_triang(graph): | |
w,v = linalg.eig(graph) | |
w,v | |
no_of_triangles = round(np.sum(w**3) / 6,1) | |
return no_of_triangles # total triangles in the matrix |
This file contains 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
# create sparse dataset | |
connections_list = [] | |
for i in range(31): | |
connections = np.random.choice(21,2) # obviously, repeated values are likely, let's see whether we get triangles too.. | |
connections_list.append(list(connections)) | |
print(connections_list) |
This file contains 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
x,y = [],[] | |
for element in connections_list: | |
xi = element[0] | |
yi = element[1] | |
x.append(xi) | |
x.append(yi) # make symmetric | |
y.append(yi) | |
y.append(xi) # make symmetric |
This file contains 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
# create sparse dataset | |
connections_list = [] | |
for i in range(31): | |
connections = np.random.choice(21,2) # obviously, repeated values are likely, let's see whether we get triangles too.. | |
connections_list.append(list(connections)) | |
print(connections_list) |
This file contains 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
graph = np.array([ | |
[0,1,1,0,0,0,0,0], | |
[1,0,1,1,1,0,0,1], | |
[1,1,0,0,0,0,0,0], | |
[0,1,0,0,1,0,1,1], | |
[0,1,0,1,0,1,0,0], | |
[0,0,0,0,1,0,0,0], | |
[0,0,0,1,0,0,0,0], | |
[0,1,0,1,0,0,0,0] | |
]) |