端到端机器学习
Joshua Stapleton
Machine Learning Engineer

逻辑回归
sklearn.linear_model.LogisticRegression支持向量分类器
sklearn.svm.SVC决策树
sklearn.tree.DecisionTreeClassifier随机森林
sklearn.ensemble.RandomForestClassifier深度学习模型
K 近邻(KNN)
XGBoost
模型:
原则:
sklearn.model_selection.train_test_split# Importing necessary libraries from sklearn.model_selection import train_test_split from sklearn.linear_model import LogisticRegression# Split the data into training and testing sets (80:20) X_train, X_test, y_train, y_test = train_test_split(features, heart_disease_y, test_size=0.2, random_state=42)# Define the models logistic_model = LogisticRegression(max_iter=200)# Train the model logistic_model.fit(X_train, y_train)
# Jane Doe 的健康数据,例如:[年龄、胆固醇、血压等] jane_doe_data = [45, 230, 120, ...]# 重塑为二维,因为 scikit-learn 需要二维类数组输入 jane_doe_data = jane_doe_data.reshape(1, -1)# 用模型预测 Jane 的心脏病诊断概率 jane_doe_probabilities = logistic_model.predict_proba(jane_doe_data) jane_doe_prediction = logistic_model.predict(jane_doe_data)
# Print the probabilities
print(f"Jane Doe's predicted probabilities: {jane_doe_probabilities[0]}")
print(f"Jane Doe's predicted health condition: {jane_doe_prediction[0]}")
Jane Doe 的预测健康状况概率: [0.2 0.8]Jane Doe 的预测健康状况: 1
端到端机器学习