-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary.py
More file actions
36 lines (31 loc) · 847 Bytes
/
Copy pathbinary.py
File metadata and controls
36 lines (31 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Fit RFOCT on a small synthetic binary classification problem."""
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from rfoct import RFOCTClassifier
X, y = make_classification(
n_samples=100,
n_features=6,
n_informative=4,
n_redundant=0,
random_state=7,
)
X_train, X_test, y_train, y_test = train_test_split(
X,
y,
test_size=0.25,
stratify=y,
random_state=7,
)
classifier = RFOCTClassifier(
n_estimators=3,
max_level=2,
max_features=2,
ga_population=2,
ga_epochs=1,
random_state=7,
)
classifier.fit(X_train, y_train)
print("classes:", classifier.classes_)
print("predictions:", classifier.predict(X_test[:5]))
print("vote shares:", classifier.predict_proba(X_test[:5]))
print("accuracy:", classifier.score(X_test, y_test))