Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submission 2 #25

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Submission scores: Mean distance=510.29, Class Imbalance Ratio=0.43 l…
…inear model
  • Loading branch information
dmitry-brazhenko committed Nov 23, 2023
commit 29d39e148c15284de66c1bbedd3df92424b0ec32
25 changes: 21 additions & 4 deletions baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import sys
from joblib import load

import scipy.stats

def softmax(x):
# Compute the exponential values for each element in the input array
Expand Down Expand Up @@ -37,13 +37,30 @@ def transform_array(arr, length):
# Add a new column 'confidence' to the DataFrame using the list of maximum confidence values.
data_frame['confidence'] = max_confidences
X = np.stack(data_frame['raw_prediction'])
print(X.shape)
data_frame['pred'] = model.predict(X)

mean_confidence = np.mean(X, axis=1)
std_confidence = np.std(X, axis=1)
max_confidence = np.max(X, axis=1)
min_confidence = np.min(X, axis=1)
sum_confidence = np.sum(X, axis=1)
median_confidence = np.median(X, axis=1)


skew_confidence = np.apply_along_axis(lambda x: scipy.stats.skew(x), axis=1, arr=X)
kurtosis_confidence = np.apply_along_axis(lambda x: scipy.stats.kurtosis(x), axis=1, arr=X)

# Combine these new features into a single 2D array
new_features = np.column_stack((mean_confidence, std_confidence, max_confidence, min_confidence, sum_confidence, median_confidence, skew_confidence, kurtosis_confidence))




data_frame['pred'] = model.predict(new_features)

#data_frame['pred'] = [x.argmax() for x in data_frame['raw_prediction']]

# Sort the DataFrame by 'confidence' in descending order.
sorted_data_frame = data_frame.sort_values(by='pred', ascending=False)
sorted_data_frame = data_frame.sort_values(by='pred', ascending=True)

# Determine the number of top records to consider for computing mean distance.
top_records_count = int(0.1 * len(data_frame))
Expand Down
Loading