<jupyter_start><jupyter_text>Logistic Regression for Price Classification<jupyter_code>train_df.shape
median = train_df['median_house_value'].median()
median
df = train_df
df['above_median'] = (df['median_house_value']-median ) > 0
df.sample(10)
P = df.drop(['median_house_value','above_median'], axis = 1)
q = df['above_median']
P.columns
from sklearn.model_selection import train_test_split
P_train , P_test, q_train, q_test = train_test_split(P,q, test_size = 0.2)
P_train.shape , P_test.shape
q_train.shape , q_test.shape
from sklearn.linear_model import LogisticRegression
logistic_model = LogisticRegression(solver='liblinear').fit(P_train,q_train)
print("Training Score:", logistic_model.score(P_train,q_train))
q_pred = logistic_model.predict(P_test)
df = pd.DataFrame({'predicted' : q_pred ,'actual':q_test})
df.head(10)
from sklearn.metrics import accuracy_score
print("Testing score:", accuracy_score(q_test,q_pred))<jupyter_output>Testing score: 0.8249037227214377
{'fraction_non_alphanumeric': 0.1260245901639344, 'fraction_numerical': 0.025614754098360656, 'mean_word_length': 8.96938775510204, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '484432', 'license': 'MIT', 'n_tokens_mistral': 381, 'n_tokens_neox': 349, 'n_words': 61, 'path': 'notebooks/2.0-ad.exploring-process-data.ipynb', 'repo_name': 'iankitdoshi/california-housing', 'size': '976'}