kaggle Learnの
「Housing Prices Competition for Kaggle Learn Users」
で質問です。
URLは下記です。
「https://www.kaggle.com/learn/machine-learning」
上記の中の”5.Exercise:Your First Machine Learning Model”
です。
下記コードです。(質問用に冗長な部分は省いています)
Python
1import pandas as pd 2from sklearn.tree import DecisionTreeRegressor 3 4# Path of the file to read 5iowa_file_path = '../input/home-data-for-ml-course/train.csv' 6home_data = pd.read_csv(iowa_file_path) 7 8#SalePriceをターゲットとする 9y = home_data['SalePrice'] 10 11#以下の機能のリストを作成する 12feature_names = ['LotArea' ,'YearBuilt' ,'1stFlrSF' ,'2ndFlrSF' ,'FullBath' ,'BedroomAbvGr' ,'TotRmsAbvGrd'] 13 14# select data corresponding to features in feature_names 15#feature_namesのフィーチャに対応するデータを選択する 16X = home_data[feature_names] 17 18#specify the model. 19#For model reproducibility, set a numeric value for random_state when specifying the model 20iowa_model = DecisionTreeRegressor(random_state=1) 21 22# Fit the model 23iowa_model.fit(X,y) 24predictions = iowa_model.predict(X)
★質問1
'#'SalePriceをターゲットとする
y = home_data['SalePrice']
上記コードは、SalePriceを予想するためにyに代入しているのでしょうか。
★質問2
'#'以下の機能のリストを作成する
feature_names = ['LotArea' ,'YearBuilt' ,'1stFlrSF' ,'2ndFlrSF' ,'FullBath' ,'BedroomAbvGr' ,'TotRmsAbvGrd']
上記コードは、リストを元にSalePriceを予想するためにfeature_namesを作成していると考えていいでしょうか
★質問3
'#' Fit the model
iowa_model.fit(X,y)
predictions = iowa_model.predict(X)
上記コードは、predictionsの中に質問2のリストを元に予想したSalePriceが格納されていると考えていいでしょうか。
以上、よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/21 04:06