text_plain_output_1.png
import numpy as np # linear algebra

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import torch

import torch

df = pd.read_csv('/kaggle/input/advancehousepriceprediction/train.csv', usecols=['SalePrice', 'MSSubClass', 'MSZoning', 'LotFrontage', 'LotArea', 'Street', 'YearBuilt', 'LotShape', '1stFlrSF', '2ndFlrSF']).dropna()

df.shape

df.drop('YearBuilt', axis=1, inplace=True)

df.columns

cat_features = ['MSSubClass', 'MSZoning', 'Street', 'LotShape']
out_features = 'SalePrice'

cat_features = np.stack([df['MSSubClass'], df['MSZoning'], df['Street'], df['LotShape']], 1)
cat_features

import torch
cat_features = torch.tensor(cat_features, dtype=torch.int64)
cat_features

cont_features = []
for i in df.columns:
    cont_features.append(i)

cont_values = np.stack([df[i].values for i in cont_features], axis=1)
cont_values = torch.tensor(cont_values, dtype=torch.float)
cont_values

cont_values.dtype

y = torch.tensor(df['SalePrice'].values, dtype=torch.float).reshape(-1, 1)
y

(cat_features.shape, cont_values.shape, y.shape)

cat_featuresz = cat_features[:4]
cat_featuresz