-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
56 lines (38 loc) · 1.56 KB
/
test.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
import math
# print(math.exp(np.zeros((5))))
print(np.exp(np.array([0, 1, 2, 3, 4, 5])))
# n_estimators = 2
# model = np.array([[1, 2, 1, 1, 0, 2], [2, 1, 0, 1, 0, 2]])
vote = np.zeros((6, 3))
for i in range(n_estimators):
vote[range(6), model[i]] += 0.5 + i
# print(model[0])
# # for i in range(n_estimators):
# # vote[model[i]] += i + 0.5
# print(vote.max(axis=1) / vote.sum(axis=1))
# n_cols = X.shape[1]
# k = int(X.size * 0.01) # Number of values to replace (1% of array size)
# # Get the indices of the smallest k values in each column
# smallest_indices = np.argsort(X, axis=0)[1]
# # smallest_indeices = np.argsort(X, axis=0)[:2]
# # smallest_indices = np.array([1, 2, 2, 2])
# print(smallest_indices)
# # Calculate the threshold value as the smallest value among the selected indices
# # threshold = X[smallest_indices, 1]
# threshold = X.values[smallest_indices, np.arange(n_cols)]
# print("threshhold: ", threshold)
# # print(np.where(X <= threshold))
# below_threshold_indices = np.where(X <= threshold)
# print(below_threshold_indices)
# Replace the smallest values in each column with the threshold
# X[smallest_indices] = threshold
# cols = X.shape[1]
# smallest_indices = np.argsort(X, axis=0)[:X.shape[0] * 0.01, np.arange(cols)]
# thresholds = X[smallest_indices[-1, np.arange(cols)]]
# # below_threshold_indices = np.where(X <= thresholds)
# # X[below_threshold_indices] = thresholds[below_threshold_indices[1]]
# print(thresholds)
# print(smallest_indices)