【算法-特征选择】reliefF算法实现

import pandas as pd
import numpy as np
from skrebate import ReliefF
from sklearn import preprocessing
import time

path_input_feature = "F:\\PaperCode\\Mypaper_python_code\\data\\feature_select\\input.tsv"
path_input_label = "F:\\PaperCode\\Mypaper_python_code\\data\\feature_select\\output.tsv"

features = pd.read_csv(path_input_feature, sep="\t")
labels = pd.read_csv(path_input_label)

# 补充缺失值
features.fillna(0, inplace = True)

# 将输入转化为数组
features = np.asarray(features.values)

# 高位数组映射坐标轴
labels = np.transpose(np.asarray(labels.values.ravel() - 1, dtype=int))

# 默认将特征范围缩放到0-1之间
min_max_scaler = preprocessing.MinMaxScaler()
features = min_max_scaler.fit_transform(features)

# 获取当前时间
current_time = int(time.time())
# 转换为localtime
localtime = time.localtime(current_time)
# 利用strftime()函数重新格式化时间
dt = time.strftime('%Y:%m:%d %H:%M:%S', localtime)
print(dt) # 返回当前时间:2021:09:09 19:17:29

####################################
#	reliefF算法实现
fs = ReliefF()
fs.fit(features, labels)
###################################

# 获取当前时间
current_time = int(time.time())
# 转换为localtime
localtime = time.localtime(current_time)
# 利用strftime()函数重新格式化时间
dt = time.strftime('%Y:%m:%d %H:%M:%S', localtime)
print(dt) # 返回当前时间:2021:09:09 19:17:29

np.savetxt('F:\\PaperCode\\Mypaper_python_code\\data\\feature_select\\counts_matrix_mean_relieff.txt', fs.feature_importances_)

# start:2024:03:13 22:01:28
# end:2024:03:14 11:20:39

input.tsv : 2477×59427维度的矩阵,行为样本,列为基因,矩阵中每个值为基因在对应样本中的表达量。
output.tsv :2477×1维度的向量,行为样本,列为标签,向量中每个值为样本的标签值。

相关推荐

  1. 算法-特征选择reliefF算法实现

    2024-03-15 22:10:02       43 阅读
  2. C语言实现选择排序算法

    2024-03-15 22:10:02       45 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-15 22:10:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-15 22:10:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-15 22:10:02       87 阅读
  4. Python语言-面向对象

    2024-03-15 22:10:02       96 阅读

热门阅读

  1. 百科 | 光伏电站如何开展运维工作?

    2024-03-15 22:10:02       41 阅读
  2. BUG解决-Modelsim打开许可证件不可用

    2024-03-15 22:10:02       38 阅读
  3. go反射实战

    2024-03-15 22:10:02       34 阅读
  4. Python中的pip工具

    2024-03-15 22:10:02       46 阅读
  5. 为什么会出现粘包这个问题

    2024-03-15 22:10:02       35 阅读
  6. 26: 翻转数的和(python)

    2024-03-15 22:10:02       47 阅读
  7. Hyperopt自动化调参工具实践-2

    2024-03-15 22:10:02       39 阅读
  8. windows的139、445端口到底在做什么

    2024-03-15 22:10:02       43 阅读