← 返回题库
初级

特征选择-相关系数

未完成 100%
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve():
    import pandas as pd
    df = pd.read_csv('https://liangdaima.com/static/data/iris.csv')
    X = df.drop('species', axis=1)
    print(X.corr().round(3))

示例

输入
solve()
期望输出
sepal_length  sepal_width  petal_length  petal_width
sepal_length         1.000       -0.118         0.872        0.818
sepal_width         -0.118        1.000        -0.428       -0.366
petal_length         0.872       -0.428         1.000        0.963
petal_width          0.818       -0.366         0.963        1.000
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码