<jupyter_start><jupyter_text>Distance formula complete<jupyter_code>dar_es_salaam = (39.28333,-6.8)
mwanza = (32.9,-2.516667)
arusha = (36.683333,-3.366667)
dodoma = (35.741944,-6.173056)
mbeya = (33.45,-8.9)
morongoro = (37.66667,-6.816667)
tanga = (39.1,-5.0666667)
kahama = (32.6,-3.8375)
tabora = (32.8,-5.016667)
zanzibar = (39.199,-6.165)
dar_es_salaam[0]
x["dar_es_salaam"] = np.sqrt( (x["longitude"] - dar_es_salaam[0])**2 + ( x["latitude"]  - dar_es_salaam[1] )**2 )
x["mwanza"] = np.sqrt( (x["longitude"] - mwanza[0])**2 + ( x["latitude"]  - mwanza[1] )**2 )
x["arusha"] = np.sqrt( (x["longitude"] - arusha[0])**2 + ( x["latitude"]  - arusha[1] )**2 )
x["dodoma"] = np.sqrt( (x["longitude"] - dodoma[0])**2 + ( x["latitude"]  - dodoma[1] )**2 )
x["mbeya"] = np.sqrt( (x["longitude"] - mbeya[0])**2 + ( x["latitude"]  - mbeya[1] )**2 )
x["morongoro"] = np.sqrt( (x["longitude"] - morongoro[0])**2 + ( x["latitude"]  - morongoro[1] )**2 )
x["tanga"] = np.sqrt( (x["longitude"] - tanga[0])**2 + ( x["latitude"]  - tanga[1] )**2 )
x["kahama"] = np.sqrt( (x["longitude"] - kahama[0])**2 + ( x["latitude"]  - kahama[1] )**2 )
x["tabora"] = np.sqrt( (x["longitude"] - tabora[0])**2 + ( x["latitude"]  - tabora[1] )**2 )
x["zanzibar"] = np.sqrt( (x["longitude"] - zanzibar[0])**2 + ( x["latitude"]  - zanzibar[1] )**2 )
x["distance_to_nearest_city"] = x.loc[: , ["dar_es_salaam","mwanza","arusha","dodoma","mbeya","morongoro","tanga","kahama","tabora","zanzibar"]].min(axis=1)
x_train, x_test, y_train, y_test = train_test_split(x,y)
col_solo = ["id", "distance_to_nearest_city", "dar_es_salaam","mwanza","arusha","dodoma","mbeya","morongoro","tanga","kahama","tabora","zanzibar"]
pipeline = make_pipeline(
LogisticRegression(C=100)
)
pipeline.fit(x_train[col_solo],y_train)
y_pred = pipeline.predict(x_test[col_solo])
accuracy_score(y_test,y_pred)
col_solo = ["id", "distance_to_nearest_city", "dar_es_salaam","mwanza","arusha","dodoma","mbeya","morongoro","tanga",\
            "kahama","tabora","zanzibar"]
x[col_solo].to_csv("cities.csv",index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.26462128475551294, 'fraction_numerical': 0.0728667305848514, 'mean_word_length': 6.32280701754386, 'pattern_counts': {'":': 0, '<': 5, '<?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': '148825', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1000, 'n_words': 118, 'path': 'distance.ipynb', 'repo_name': 'crawftv/DS-Unit-2-Challenge', 'size': '2086'}