

`inputs = data[:,0:1]`がエラーなんですけどどうしたらよいでしょうか(画像は使っているデータセットです）

**実行環境:**  
Google Colab

**ソースコード:**

[code]

    import numpy as np
    import matplotlib.pyplot as plt
    from sklearn import linear_model
    from sklearn.preprocessing import StandardScaler
    from sklearn.linear_model import Lasso
    with open("Mjob(使うデータ).csv", 'r') as file:
     line = file.readline()
     data = np.loadtxt(file, delimiter=',', usecols=(1,2)
    
    inputs = data[:,0:1]
    outputs = data[:,-1]
    
    #標準化
    scaler = StandardScaler()
    scaler.fit(inputs)
    x_scaler = scaler.transform(inputs)
    
    #regr = linear_model.LinearRegression()
    regr = Lasso()
    regr.fit(inputs, outputs)
    #regr.fit(x_scaler,outputs)
    
    print('Coefficients: \n', regr.coef_)
    
    predict = regr.predict(inputs)
    #print('R2 score:{0}'.format(r2_score(outputs,predict)))
    print('Coefficients:\n',regr.coef_)
    
    # plot
    """x_min = np.min(inputs)
    x_max = np.max(inputs)
    plot_x = np.arange(x_min,x_max,0.1)
    plot_x = plot_x[:,np.newaxis] # convert [*,*,*,..] ->[[*],[*],[*],...]
    plt.scatter(inputs[:,0], outputs, color='black')
    plt.plot(plot_x[:,0], regr.predict(plot_x), color='red')
    plt.show()
    """
    
[/code]


CC BY-SA 4.0
2022-07-03T09:22:36.017
89736
2022-07-03T11:19:52.923
2022-07-03T11:19:52.923
3060
53264
question
python
Pythonのエラーの原因を教えてください