forked from mathigatti/midi2foxdot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bad_guy_degrees.py
24 lines (21 loc) · 1.16 KB
/
bad_guy_degrees.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np
import pandas as pd
from sklearn.decomposition import FastICA
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.pipeline import make_pipeline, make_union
from tpot.builtins import StackingEstimator
# NOTE: Make sure that the outcome column is labeled 'target' in the data file
tpot_data = pd.read_csv('PATH/TO/DATA/FILE', sep='COLUMN_SEPARATOR', dtype=np.float64)
features = tpot_data.drop('target', axis=1)
training_features, testing_features, training_target, testing_target = \
train_test_split(features, tpot_data['target'], random_state=None)
# Average CV score on the training set was: 0.7386904761904762
exported_pipeline = make_pipeline(
StackingEstimator(estimator=RandomForestClassifier(bootstrap=True, criterion="entropy", max_features=0.15000000000000002, min_samples_leaf=3, min_samples_split=14, n_estimators=100)),
FastICA(tol=1.0),
KNeighborsClassifier(n_neighbors=5, p=2, weights="distance")
)
exported_pipeline.fit(training_features, training_target)
results = exported_pipeline.predict(testing_features)