Skip to content

Instantly share code, notes, and snippets.

View hellozeyu's full-sized avatar

Zeyu Zhang hellozeyu

  • NYC Data Science Academy
  • NEW YORK
View GitHub Profile
@hellozeyu
hellozeyu / OOP.py
Last active January 26, 2024 17:31
import numpy as np
import pygame
pygame.init()
WIDTH, HEIGHT = 400, 600
SCREEN = pygame.display.set_mode((WIDTH,HEIGHT))
GameOn = True
CLOCK = pygame.time.Clock()
FRAMERATE = 60
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hellozeyu
hellozeyu / stacking.py
Created July 7, 2019 14:25
stacking for kaggle competition
import numpy as np
from sklearn.model_selection import KFold
from sklearn.metrics import mean_squared_error
from sklearn.base import clone
def transformer(y, func=None):
"""Transforms target variable and prediction"""
if func is None:
return y
else:
@hellozeyu
hellozeyu / preprocess.py
Created July 7, 2019 14:24
preprocess the data before fitting the model
# Idea borrowed from this script: https://www.kaggle.com/serigne/stacked-regressions-top-4-on-leaderboard
def impute(all_data):
# PoolQC : data description says NA means "No Pool". That make sense, given the huge ratio of missing value (+99%) and majority of houses have no Pool at all in general.
all_data["PoolQC"] = all_data["PoolQC"].fillna("None")
# MiscFeature : data description says NA means "no misc feature"
all_data["MiscFeature"] = all_data["MiscFeature"].fillna("None")
@hellozeyu
hellozeyu / restore_packages.R
Created October 27, 2017 15:17 — forked from arne-cl/restore_packages.R
save/load/install a list of your currently installed R packages
# restore_packages.R
#
# installs each package from the stored list of packages
# source: http://hlplab.wordpress.com/2012/06/01/transferring-installed-packages-between-different-installations-of-r/
load("~/installed_packages.rda")
for (count in 1:length(installedpackages)) {
install.packages(installedpackages[count])
}