Skip to content

Instantly share code, notes, and snippets.

View infontology's full-sized avatar
💭
Coding for flow

Simon Winter infontology

💭
Coding for flow
View GitHub Profile
@infontology
infontology / spotify_listor_med_spaar.ipynb
Last active October 9, 2020 09:40
Jupyter notebook som hämtar användares Spotify-spellistor och spåren på dessa och sparar till fil.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@infontology
infontology / remove_correlating_columns.py
Last active November 25, 2019 19:04
Om man har en korrelationsmatris och vill veta vilka dimensioner man kanske kan ta bort för att de korrelerar väldigt mycket
#Korrelationsmatrisen
corr = df_cancer.corr()
def correlation_columns (correlation_matrix, threshold):
all_cols = correlation_matrix.columns
cols = [all_cols[correlation_matrix[column]>threshold] for column in correlation_matrix]
cols = [col.tolist() for col in cols]
result = [(all_cols[index], col) for index, col in enumerate(cols)]
return result
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import pickle
import requests
#Skapa picklad fil från np.array (db_contents)
with open('pick.npy', 'wb') as pickle_file:
pickle.dump(db_contents, pickle_file)
#Läsa in filen lokalt.
with open('pick.npy', 'rb') as pickle_file:
groda = pickle.load(pickle_file) #groda blir snällt en np.array igen.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@infontology
infontology / spaerrad_text.py
Created February 14, 2018 08:42
Slår ihop s p ä r r a d text till vanlig stil
pattern = re.compile('(?<=\s\S)\s(?!\S\S)', re.S)
re.sub(pattern, '', text)
import os
import shutil
raw_ext = '.NEF'
jpg_ext = '.JPG'
destination = 'raws'
for filename in os.listdir('.'):
(shortname, extension) = os.path.splitext(filename)
@infontology
infontology / text-processer.ipynb
Created January 5, 2018 08:46
Ett första försök att förstå datastrukturer vid machine learning med text
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@infontology
infontology / read_from_db.py
Created December 25, 2017 21:05
Läs från databasen (i en Jupyter notebook)
conn = sqlite3.connect('../livs.db') # Create db and establish connection
conn.row_factory = sqlite3.Row
curs = conn.cursor()
result = []
rows = curs.execute('select * from livs limit 4000')
for row in rows:
result.append(row)
db_contents = np.array(result)
print (db_contents)
@infontology
infontology / leka_med_kluster.ipynb
Created November 29, 2017 08:18
Den här anteckningsboken jämför Livsmedelsverkets metadata med de grupper man kan få om man grupperar endast på grundval av näringsvärden. Data kommer från Livsmedelsverkets Livsmedelsdatabas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.