<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Load data
Generated in notebook data_exploration_numerical_features.ipynb
Step1:  Recreate transformed (standardized) sale price
Step2:  Ordinary Least Squares
Step3:  As can be seen below, using more numerical values improves R-squared to 0.88 which is pretty good, though there's of course a risk of overfitting.
Step4:  Cross validation
Step5:  Make a submission
Step6:  Scale the result
<ASSISTANT_TASK:>
Python Code:
dfnum = pd.read_csv('transformed_numerical_dataset_imputed.csv', index_col=['Dataset','Id'])
dfnum.head()
dfcat = pd.read_csv('cleaned_categorical_vars_with_colz_sorted_by_goodness.csv', index_col=['Dataset','Id'])
dfcat.head()
dfcat.head()
df = pd.concat([dfnum, dfcat.iloc[:, :ncat]], axis=1)
df.shape
Explanation: Load data
Generated in notebook data_exploration_numerical_features.ipynb
End of explanation
target = pd.read_csv('../data/train_target.csv')
scaler = sk.preprocessing.StandardScaler()
def transform_target(target):
    logtarget = np.log1p(target / 1000)
    return scaler.fit_transform(logtarget)
def inverse_transform_target(target_t):
    logtarget = scaler.inverse_transform(target_t)
    return np.expm1(logtarget) * 1000
target_t = transform_target(target)
# Test
assert all(target == inverse_transform_target(target_t))
Explanation: Recreate transformed (standardized) sale price
End of explanation
data = df.loc['train',:].copy()
data['SalePrice'] = target_t
data.columns
desc = 'SalePrice' + \
    ' ~ ' + \
    ' + '.join(data.drop('SalePrice', axis=1).iloc[:, :-ncat]) + \
    ' + ' + \
    ' + '.join('C({})'.format(col) for col in data.drop('SalePrice', axis=1).iloc[:, -ncat:])
desc
Explanation: Ordinary Least Squares
End of explanation
regression2 = smapi.ols(desc, data=data).fit()
regression2.summary()
Explanation: As can be seen below, using more numerical values improves R-squared to 0.88 which is pretty good, though there's of course a risk of overfitting.
End of explanation
def get_data(X, y):
    df = X.copy()
    df['SalePrice'] = y
    return df
def ols3(X, y):
    data = get_data(X, y)
    return smapi.ols(desc, data=data)
Explanation: Cross validation
End of explanation
submission_t = regression2.predict(df.loc['test',:])
Explanation: Make a submission
End of explanation
submission = inverse_transform_target(submission_t)
submission
def save(filename, submission):
    df = pd.DataFrame(data={
            "Id": np.arange(len(submission)) + 1461,
            "SalePrice": submission
            })
    df.to_csv(filename, index=False)
    
save('ols_full_{}.csv'.format(ncat), submission)
Explanation: Scale the result
End of explanation
<END_TASK>