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
'''Implementation and of K Means Clustering | |
Requires : python 2.7.x, Numpy 1.7.1+''' | |
import numpy as np | |
def kMeans(X, K, maxIters = 10, plot_progress = None): | |
centroids = X[np.random.choice(np.arange(len(X)), K), :] | |
for i in range(maxIters): | |
# Cluster Assignment step | |
C = np.array([np.argmin([np.dot(x_i-y_k, x_i-y_k) for y_k in centroids]) for x_i in X]) |
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
Codes for Machine Learning Foundations(NTU) | |
台湾国立大学《机器学习基石》(Coursera版)相关的代码、编程作业等。 | |
课程地址:https://class.coursera.org/ntumlone-001/ |
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
#-*- coding: utf-8 -*- | |
import re | |
import nltk | |
from nltk.tokenize import RegexpTokenizer | |
from nltk import bigrams, trigrams | |
import math | |
stopwords = nltk.corpus.stopwords.words('portuguese') |
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 os | |
import time | |
import string | |
import pickle | |
from operator import itemgetter | |
from nltk.corpus import stopwords as sw | |
from nltk.corpus import wordnet as wn | |
from nltk import wordpunct_tokenize |
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
#!/bin/sh | |
# installation of Oracle Java JDK. | |
sudo apt-get -y update | |
sudo apt-get -y install python-software-properties | |
sudo add-apt-repository -y ppa:webupd8team/java | |
sudo apt-get -y update | |
sudo apt-get -y install oracle-java7-installer | |
# Installation of commonly used python scipy tools |
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 numpy as np | |
import matplotlib.pyplot as plt | |
plt.rcParams['figure.figsize'] = (10, 8) | |
# intial parameters | |
n_iter = 50 | |
sz = (n_iter,) # size of array | |
x = -0.37727 # truth value (typo in example at top of p. 13 calls this z) |
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
# List unique values in a DataFrame column | |
pd.unique(df.column_name.ravel()) | |
# Convert Series datatype to numeric, getting rid of any non-numeric values | |
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True) | |
# Grab DataFrame rows where column has certain values | |
valuelist = ['value1', 'value2', 'value3'] | |
df = df[df.column.isin(valuelist)] |
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
# coding=utf-8 | |
import pandas as pd | |
import itertools | |
import time | |
import multiprocessing | |
from typing import Callable, Tuple, Union | |
def groupby_parallel(groupby_df: pd.core.groupby.DataFrameGroupBy, | |
func: Callable[[Tuple[str, pd.DataFrame]], Union[pd.DataFrame, pd.Series]], |
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 https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=24679&start=50 | |
hdmi_ignore_cec_init=1 | |
hdmi_drive=2 | |
disable_overscan=1 | |
hdmi_ignore_edid=0xa5000080 | |
hdmi_group=2 | |
hdmi_mode=87 | |
hdmi_timings=2560 1 64 64 96 1080 1 3 10 31 0 0 1 60 0 185580000 8 |
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
package org.logician.sorta | |
import scala.util.Random | |
import scala.math | |
import scala.collection.mutable | |
import scala.collection.mutable.ArrayBuffer | |
/** | |
* Created with IntelliJ IDEA. | |
* User: Austin |
OlderNewer