<jupyter_start><jupyter_text>Read the CSV and Perform Basic Data Cleaning<jupyter_code>df = pd.read_csv("exoplanet_data.csv")
# Drop the null columns where all values are null
df = df.dropna(axis='columns', how='all')
# Drop the null rows
df = df.dropna()
df.head()
df2 = df[df['koi_disposition'] != 'CANDIDATE']<jupyter_output><empty_output><jupyter_text>Select your features (columns)<jupyter_code># Set features. This will also be used as your x values.
selected_features = df2[['koi_period','koi_time0bk','koi_impact','koi_depth','koi_prad','koi_teq','koi_insol','koi_steff','koi_duration','koi_slogg','koi_srad','ra','dec','koi_kepmag']]
selected_features.head()
y = df2['koi_disposition']
y2 = y.replace({'CONFIRMED': 1,"FALSE POSITIVE":0})

y3 = y2.astype(int).values.reshape(-1, 1)
from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(selected_features, y3, random_state=42)
X_train.head()<jupyter_output><empty_output><jupyter_text>Pre-processingScale the data using the MinMaxScaler and perform some feature selection<jupyter_code># Scale your data
from sklearn.preprocessing import MinMaxScaler
X_scaler = MinMaxScaler().fit(X_train)
y_scaler = MinMaxScaler().fit(y_train)
X_train_scaled = X_scaler.transform(X_train)
X_test_scaled = X_scaler.transform(X_test)
y_train_scaled = y_scaler.transform(y_train)
y_test_scaled = y_scaler.transform(y_test)
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import mean_squared_error

model = LogisticRegression()
model.fit(X_train_scaled, y_train_scaled)

predictions = model.predict(X_train_scaled)
r2 = model.score(X_train_scaled, y_train_scaled)
MSE = mean_squared_error(y_train_scaled, predictions)

print(r2)
print(f"Training Data Score: {model.score(X_train_scaled, y_train)}")
print(f"Testing Data Score: {model.score(X_test_scaled, y_test)}")<jupyter_output><empty_output><jupyter_text>Hyperparameter TuningUse `GridSearchCV` to tune the model's parameters<jupyter_code># Create the GridSearchCV model
# Train the model with GridSearch
print(grid2.best_params_)
print(grid2.best_score_)<jupyter_output><empty_output><jupyter_text>Save the Model<jupyter_code># save your model by updating "your_name" with your name
# and "your_model" with your model variable
# be sure to turn this in to BCS
# if joblib fails to import, try running the command to install in terminal/git-bash
import joblib
filename = 'your_name.sav'
joblib.dump(your_model, filename)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11199364575059571, 'fraction_numerical': 0.007148530579825258, 'mean_word_length': 8.725868725868725, 'pattern_counts': {'":': 1, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '321025', 'license': 'ADSL', 'n_tokens_mistral': 932, 'n_tokens_neox': 910, 'n_words': 191, 'path': 'model_tensor.ipynb', 'repo_name': 'gpfundt/ML-1', 'size': '2518'}