arf and csv test

This commit is contained in:
2021-06-03 23:33:54 +02:00
parent 7404566e7a
commit ff80fe6172
4 changed files with 1296 additions and 2 deletions

38
k.py
View File

@@ -3,10 +3,35 @@ from sklearn.datasets import load_wine
from mfs import MFS
from mfs.Metrics import Metrics
from stree import Stree
import numpy as np
from scipy.io import arff
from sklearn.preprocessing import StandardScaler
mfsc = MFS(discrete=False)
mfsd = MFS(discrete=True)
X, y = load_wine(return_X_y=True)
# Xo, y = load_wine(return_X_y=True)
# X = Xo.copy()
# scaler = StandardScaler()
# for c in range(X.shape[1]):
# X[:, c] = scaler.fit_transform(X[:, c].reshape(-1, 1)).reshape(-1)
# data = np.genfromtxt("balance-scale.csv")
# X = data[:, -1:]
# y = data[:, -1]
data, meta = arff.loadarff(
"/Users/rmontanana/Code/stree_datasets/data/tanveer/balance-scale/balance-scale.arff"
)
train = np.array([data["f1"], data["f2"], data["f3"], data["f4"]])
y = data["clase"]
X = train.T
for c in range(X.shape[1]):
print(f"Mean: {np.mean(X[:,c])} Std: {np.std(X[:,c])}")
m, n = X.shape
print("* Differential entropy in X")
for i in range(n):
@@ -39,5 +64,14 @@ clf = Stree(random_state=0)
print("cfs discreto", clf.fit(X[:, cfs_d], y).score(X[:, cfs_d], y))
print("cfs continuo", clf.fit(X[:, cfs_f], y).score(X[:, cfs_f], y))
clf = Stree(random_state=0)
subf = fcfb_f[:6]
# subf = fcfb_f[:6]
subf = fcfb_f
print("fcfb", clf.fit(X[:, subf], y).score(X[:, subf], y))
for c in range(X.shape[1]):
for k in range(X.shape[1]):
ac = 0
for v in range(X[:, c].shape[0]):
if X[v, c] == X[v, k]:
ac += 1
print(f"{c} {k} {ac}")