预测未知的药物-靶标对之间是否可能存在互作关系的代码
时间: 2024-01-25 17:04:16 浏览: 119
以下是一个简单的基于机器学习的药物-靶标互作预测模型的示例代码:
```python
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.ensemble import RandomForestClassifier
# Load the dataset
data = pd.read_csv('drug_target_interaction.csv')
# Split the dataset into training and testing sets
train, test = train_test_split(data, test_size=0.2, random_state=42)
# Define the features and target variable
X_train = train.drop('Interaction', axis=1)
y_train = train['Interaction']
X_test = test.drop('Interaction', axis=1)
y_test = test['Interaction']
# Train the model
model = RandomForestClassifier()
model.fit(X_train, y_train)
# Make predictions on the testing set
y_pred = model.predict(X_test)
# Evaluate the model
accuracy = accuracy_score(y_test, y_pred)
print("Accuracy:", accuracy)
```
在这个示例代码中,我们使用了随机森林分类器作为我们的模型。我们首先加载了一个包含药物-靶标互作数据的 CSV 文件,并将其拆分为训练和测试集。我们然后定义了特征和目标变量,并使用随机森林分类器训练了一个模型。最后,我们使用测试集进行预测,并计算了模型的准确性。
阅读全文