Skip to content

Instantly share code, notes, and snippets.

@davidzhaodz
Last active January 9, 2021 12:14
Show Gist options
  • Save davidzhaodz/e06f4cb66b936a694430967622412816 to your computer and use it in GitHub Desktop.
Save davidzhaodz/e06f4cb66b936a694430967622412816 to your computer and use it in GitHub Desktop.
# Get features at event dates
X = data.loc[labels.index, :]
y = labels['bin']
# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False)
# Setting random forest parameters
n_estimator = 1000
depth = 2
RANDOM_STATE = 0
rf = RandomForestClassifier(max_depth=depth, n_estimators=n_estimator,
criterion='entropy', class_weight='balanced_subsample',
random_state=RANDOM_STATE)
# Fitting our model
rf.fit(X_train, y_train)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment