完整FScanpy包

This commit is contained in:
Chenlab 2025-05-29 14:40:01 +08:00
parent d8a3fdd2de
commit 7587bd632b
8 changed files with 44 additions and 16 deletions

14
FScanpy.egg-info/PKG-INFO Normal file
View File

@ -0,0 +1,14 @@
Metadata-Version: 2.4
Name: FScanpy
Version: 1.0.0
Summary: PRF prediction tool
Author: FScanpy Developer
Author-email: FScanpy Developer <example@example.com>
Requires-Python: >=3.7
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: tensorflow
Requires-Dist: scikit-learn
Requires-Dist: wrapt>=1.10.11
Dynamic: author
Dynamic: requires-python

View File

@ -0,0 +1,14 @@
README.md
pyproject.toml
setup.py
FScanpy/__init__.py
FScanpy/predictor.py
FScanpy/utils.py
FScanpy.egg-info/PKG-INFO
FScanpy.egg-info/SOURCES.txt
FScanpy.egg-info/dependency_links.txt
FScanpy.egg-info/requires.txt
FScanpy.egg-info/top_level.txt
FScanpy/features/__init__.py
FScanpy/features/cnn_input.py
FScanpy/features/sequence.py

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,5 @@
numpy
pandas
tensorflow
scikit-learn
wrapt>=1.10.11

View File

@ -0,0 +1 @@
FScanpy

View File

@ -26,11 +26,8 @@ class PRFPredictor:
try:
# 加载模型
self.gb_model = self._load_pickle(os.path.join(model_dir, 'GradientBoosting_all.pkl'))
self.cnn_model = self._load_pickle(os.path.join(model_dir, 'BiLSTM-CNN_all.pkl'))
self.voting_model = self._load_pickle(os.path.join(model_dir, 'Voting_all.pkl'))
# 初始化特征提取器和CNN处理器使用与训练时相同的序列长度
self.gb_seq_length = 33 # HistGradientBoosting使用的序列长度
self.cnn_seq_length = 399 # BiLSTM-CNN使用的序列长度
@ -145,14 +142,12 @@ class PRFPredictor:
# 出错时设置概率为0
cnn_prob = 0.0
# 投票模型预测
# 使用4:6的加权平均替代投票模型
try:
# 确保投票模型输入是二维数组 (1, n_features)
voting_input = np.array([[gb_prob, cnn_prob]])
voting_prob = self.voting_model.predict_proba(voting_input)[0][1]
voting_prob = 0.4 * gb_prob + 0.6 * cnn_prob
except Exception as e:
print(f"投票模型预测时出错: {str(e)}")
# 出错时使用两个模型的平均值
print(f"计算加权平均时出错: {str(e)}")
# 出错时使用简单平均
voting_prob = (gb_prob + cnn_prob) / 2
return {
@ -373,14 +368,12 @@ class PRFPredictor:
# 出错时设置概率为0
cnn_prob = 0.0
# 投票模型预测
# 使用4:6的加权平均替代投票模型
try:
# 确保投票模型输入是二维数组 (1, n_features)
voting_input = np.array([[gb_prob, cnn_prob]])
voting_prob = self.voting_model.predict_proba(voting_input)[0][1]
voting_prob = 0.4 * gb_prob + 0.6 * cnn_prob
except Exception as e:
print(f"投票模型预测序列 {i+1} 时出错: {str(e)}")
# 出错时使用两个模型的平均值
print(f"计算加权平均时出错: {str(e)}")
# 出错时使用简单平均
voting_prob = (gb_prob + cnn_prob) / 2
results.append({

Binary file not shown.