系外行星的随机森林
bem的Python项目详细描述
边界元:超越与随机森林的系外行星质量半径关系
根据行星和恒星参数预测系外行星的半径
布兰卡·艾德梅·马奎斯
与玛丽·居里一起在法国从事核物理研究的葡萄牙科学家
安装BEM
pip install bem
或
git clone https://github.com/soleneulmer/bem.git
cd bem
python setup.py install
一个简单的决策树
预测系外行星半径
如何运行BEM:
1.加载数据集和模型
# Load exoplanet and solar system planets datasetdataset= bem.load_dataset()# Plot the dataset radius as a function of mass and equilibrium temperature bem.plot_dataset(dataset)
# Build the random forest model and predict radius of the dataset regr, y_test_predict, _, train_test_sets= bem.random_forest_regression(dataset)
2.预测行星的半径
我的星球=行星质量, 半长轴, 偏心率, 恒星半径, 恒星有效温度, 恒星质量]
# Predict a new radius radius, my_pred_planet= bem.predict_radius(my_planet=np.array([[1.63, 0.034, 0.02, 0.337, 3505.0, 0.342]]), my_name=np.array(['GJ 357 b']), regr=regr, jupiter_mass=False)
3.计算半径预测的误差线
# Load exoplanet and solar system planets dataset with uncertaintiesdataset_errors= bem.load_dataset_errors()# Compute the error bars for the test set planets radii_test_output_error, _= bem.computing_errorbars(regr, dataset_errors, train_test_sets)# Plot the test set, true radius versus RF predicted radius bem.plot_true_predicted(train_test_sets, y_test_predict, radii_test_output_error)
4.径向速度数据集
# Load the radial velocity datasetdataset_rv= bem.load_dataset_RV()# Predict the radius of the RV datasetradii_RV_RF= regr.predict(dataset_rv)# Plot the predictions of the RV dataset bem.plot_dataset(dataset_rv, predicted_radii=radii_RV_RF, rv=True)
5。诊断图
# Plot the learning curve bem.plot_learning_curve(regr, dataset)# Plot the validation curves bem.plot_validation_curves(regr, dataset, name='features') bem.plot_validation_curves(regr, dataset, name='tree') bem.plot_validation_curves(regr, dataset, name='depth')
6.石灰说明
查看他们的github
# Explain the RF predictions# of the exoplanets from the test set bem.plot_LIME_predictions(regr, dataset, train_test_sets)# LIME explanation for your planet# in this case GJ 357 b bem.plot_LIME_predictions(regr, dataset, train_test_sets, my_pred_planet=my_pred_planet, my_true_radius=1.166)