Instantly share code, notes, and snippets.

View bact2.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=C0103, C0321, C0330
"""1-D Bacterium class example"""
from random import randint as rnd
import gc
import time
from matplotlib import pyplot as plt
from datetime import datetime as dt
View kNN_example.r
library(class)
library(gmodels)
set.seed(6)
df <- data.frame(A = c(rnorm(30, 0), rnorm(30, 3)),
B = c(rnorm(30, 0), rnorm(30, 3)),
Group = factor(c(rep("G1", 30), rep("G2", 30))))
# use 33% of data for training and 67% is for test
i <- sample(2, nrow(df), replace = TRUE, prob = c(0.67, 0.33))
train.df <- df[i == 2, -3] # do not include last column
train.cl <- df[i == 2, 3] # training result cluters
View hw1.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View file.py
import os
if '__file__' in globals():
cdir = os.path.dirname(os.path.realpath(__file__))
else:
cdir = os.getcwd()