Skip to content

Instantly share code, notes, and snippets.

View ackjake's full-sized avatar

J_Headings ackjake

  • State Farm
  • Atlanta, GA
View GitHub Profile
def leave_one_out(df_train, df_test, var, noise=.01, drop=True):
new_var = 'mean_{}'.format(var)
df_train[new_var] = np.nan
df_test[new_var] = np.nan
# training set
loo = LeaveOneOut()
for train_index, test_index in tqdm_notebook(loo.split(df_train)):
loo_train = df_train.iloc[train_index]
def get_target_mean(df_train, df_test, var, target, NFOLDS, NOISE):
"""
Creates out of fold averages by the categorical variable passed.
Decreasing the number of folds and increasing the noise can help
prevent over fitting the training set.
"""
df_train['mean_{}'.format(var)] = np.nan
df_test['mean_{}'.format(var)] = np.nan
static bool CheckBad(int[] a)
{
for (int i = 0; i < a.Length; i++)
if (a[i] != i)
return false;
return true;
}
if (N >= 2)
{
@ackjake
ackjake / Tic Tac Toe checker
Created December 6, 2012 22:03
Checks the outcome of a tic tac toe game.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Tic_Tac_Toe_Checker
{
class Program
{
static void Main(string[] args) //testing method