<jupyter_start><jupyter_text>Applying the PCA<jupyter_code>from sklearn.decomposition import PCA

pc=PCA(n_components=None)
finaltrain=pc.fit_transform(finaltrain)
(pc.explained_variance_ratio_)
pc=PCA(n_components=120)
finaltrain=pc.fit_transform(finaltrain)
(pc.explained_variance_ratio_)
finaltrain1=pd.DataFrame(finaltrain)
finaltrain1.shape
from sklearn.cross_validation import train_test_split
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.3,random_state=1)<jupyter_output><empty_output><jupyter_text>prediction on test data<jupyter_code>housing_test.head()
sns.heatmap(housing_test.isnull())
plt.show()
#converting the train data to dummies
new_test=pd.get_dummies(housing_test)
sc1=StandardScaler()
new_test_st=sc.fit_transform(new_test)
new_test1=pd.DataFrame(new_test_st)
new_test1.columns=new_test.columns
new_test1.head()
finaltest=new_test1.drop('Id',axis=1)
finaltest.head()
#Creating the copy of scaled data
finaltest.copy=finaltest
pc1=PCA(n_components=None)
finaltest=pc1.fit_transform(finaltest)
(pc1.explained_variance_ratio_)
pc1=PCA(n_components=120)
finaltest=pc1.fit_transform(finaltest)
(pc1.explained_variance_ratio_)
finaltest1=pd.DataFrame(finaltest)
finaltest1.shape<jupyter_output><empty_output><jupyter_text>Applying PCA without salesPrice<jupyter_code>finalx=pc.fit_transform(x)

#linrig.fit()-IV's as a DataFrame,DV as series
from sklearn.linear_model import LinearRegression
model=LinearRegression()
model.fit(finalx,y)
pred_x=model.predict(finalx)
pred_testlr=model.predict(finaltest)
pred_testlr
pred_test_sales=pd.DataFrame({'ID':housing_test.Id,'SalePrice':pred_testlr})
pred_test_sales.to_csv('Housing.csv',index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11208920187793427, 'fraction_numerical': 0.014671361502347418, 'mean_word_length': 13.956140350877194, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '228411', 'license': 'MIT', 'n_tokens_mistral': 677, 'n_tokens_neox': 656, 'n_words': 73, 'path': 'Unsupervised_Clustering/Practice_Notebooks/Day4_Housing_OtherSub.ipynb', 'repo_name': 'Aujasvi-Moudgil/ML', 'size': '1704'}