Spaces:
Running
Running
File size: 448 Bytes
bdf9096 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import numpy as np
import pandas as pd
from sklearn.impute import SimpleImputer
def ensure_matrix_symmetry(matrix):
return 0.5 * (matrix + matrix.T)
def insert_missing_data(matrix):
imp_mean = SimpleImputer(missing_values=np.nan, strategy='mean')
imp_mean.fit(matrix.drop(['log'], axis=1))
imp_df = imp_mean.transform(matrix.drop(['log'], axis=1))
result = pd.DataFrame(imp_df, columns = matrix.columns[1:])
return result
|