Python-Programm, das einen maschinellen Lernalgorithmus zur Vorhersage des Ferritinspiegels mit…

Jan 15 2023
.

import pandas as pd
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

# Load the data
data = pd.read_csv("patient_data.csv")

# Split the data into features (other test results) and target (ferritin test result)
X = data.drop("ferritin", axis=1)
y = data["ferritin"]

# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

# Create and train the model
model = RandomForestRegressor(n_estimators=100)
model.fit(X_train, y_train)

# Make predictions on the test data
y_pred = model.predict(X_test)

# Evaluate the model
acc = accuracy_score(y_test, y_pred)
print("Accuracy:", acc)