Skip to content

Instantly share code, notes, and snippets.

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

Omar Eltayeby otayeby

🏠
Working from home
View GitHub Profile
# This works in MACs
# Dataframe can also be used in R
import pandas as pd
##reading a csv file
df = pd.read_csv("PATH WHERE YOUR FILE IS SAVED/filename.csv", encoding='utf-8',lineterminator = '\n',index_col=0)
##writing a csv file
df.to_csv("PATH WHERE YOU WANT TO SAVE YOUR FILE/filename.csv",quoting=csv.QUOTE_NONNUMERIC, date_format='%Y-%m-%d %H:%M:%S', encoding='utf-8',line_terminator = '\n')
@wesslen
wesslen / stm-labels-five-words.R
Created February 28, 2018 03:12
get five words for stm topics
labels <- sageLabels(ctmFit, n = 5)
topicsNames <- sapply(1:30, function(x) paste0(labels$marginal$frex[x,], collapse = " + "))
@wesslen
wesslen / twitter-trolls.Rmd
Last active March 19, 2018 20:26
troll-tweets Rmd
---
title: "Analyzing Russian Trolls: Tidyverse & Text"
author: "Ryan Wesslen"
date: "2/21/2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, warning = FALSE)
```
@nornagon
nornagon / smith_waterman.py
Created July 21, 2017 04:07
Smith-Waterman Python implementation
import numpy as np
def smith_waterman(a: str, b: str, alignment_score: float = 1, gap_cost: float = 1) -> float:
"""
Compute the Smith-Waterman alignment score for two strings.
See https://en.wikipedia.org/wiki/Smith%E2%80%93Waterman_algorithm#Algorithm
This implementation has a fixed gap cost (i.e. extending a gap is considered
free). In the terminology of the Wikipedia description, W_k = {c, c, c, ...}.
This implementation also has a fixed alignment score, awarded if the relevant
@WittmannF
WittmannF / compare-svm-kernels.py
Last active March 5, 2024 03:23
Visualization of SVM Kernels Linear, RBF, Poly and Sigmoid on Python (Adapted from: http://scikit-learn.org/stable/auto_examples/classification/plot_classifier_comparison.html)
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
from sklearn.cross_validation import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.datasets import make_moons, make_circles, make_classification
from sklearn.svm import SVC
h = .02 # step size in the mesh
@bsweger
bsweger / useful_pandas_snippets.md
Last active March 20, 2024 21:09
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

@fideloper
fideloper / usevm.md
Created June 6, 2012 02:24
You should develop in a Virtual Machine

#You should do all your LAMP development in a Virtual Machine

##Here's Why:

Many of us develop on Macintoshes. There are many reasons for this, but one of them is that it's based on a Unix platform of some sort. This allows us to run common server software such as Apache, Ruby, Python and Nodejs on our Macs.

Our computers become powerful develoment machines similar to the servers our apps will eventually live on.

Sometime we start our computer only to find Apache won't start, or MySQL can't create a PID file, or we've updated to Mountain Lion and Apache needs to be reconfigured. Death!