<jupyter_start><jupyter_text>Read the CSV and Perform Basic Data Cleaning<jupyter_code>exoplanets = pd.read_csv("Resources/exoplanet_data.csv")
# Drop the null columns where all values are null
exoplanets = exoplanets.dropna(axis='columns', how='all')
# Drop the null rows
exoplanets = exoplanets.dropna()
exoplanets.head()
exoplanets.describe()<jupyter_output><empty_output><jupyter_text>Select your features (columns)<jupyter_code># Set features. This will also be used as your x values.
target = exoplanets["koi_disposition"]

data = exoplanets.drop("koi_disposition", axis=1)
feature_names = data.columns
data.head()<jupyter_output><empty_output><jupyter_text>Create a Train Test SplitUse `koi_disposition` for the y values<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(data, target, 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
scaler = MinMaxScaler()
X_scaler_train = scaler.fit(X_train)
X_scaler_test = scaler.fit(X_test)
X_train_scaled = X_scaler_train.transform(X_train)
X_test_scaled = X_scaler_test.transform(X_test)
from sklearn.linear_model import LogisticRegression
model = LogisticRegression(max_iter=1000)
model.fit(X_train_scaled, y_train)
model.predict(X_test_scaled)<jupyter_output><empty_output><jupyter_text>Train the Model<jupyter_code>print(f"Training Data Score: {model.score(X_train_scaled, y_train)}")
print(f"Testing Data Score: {model.score(X_test_scaled, y_test)}")
from sklearn.metrics import confusion_matrix, plot_confusion_matrix
confusion_matrix(y_test, model.predict(X_test_scaled))
#plot_confusion_matrix(model, X_test, y_test, cmap='Blues')
y_test.unique()
y_train.unique()<jupyter_output><empty_output><jupyter_text>Hyperparameter TuningUse `GridSearchCV` to tune the model's parameters<jupyter_code># Create the GridSearchCV model
from sklearn.model_selection import GridSearchCV
param_grid = {'penalty':['l1', 'l2', 'elasticnet', 'none']
                }
grid = GridSearchCV(model, param_grid, verbose=3)
# Train the model with GridSearch
grid.fit(X_train, y_train)
#This GridSearchCV method did not work. 
print(grid.best_params_)
print(grid.best_score_)<jupyter_output>{'penalty': 'none'}
0.667933837387843
{'fraction_non_alphanumeric': 0.10219280099296649, 'fraction_numerical': 0.01075713694662805, 'mean_word_length': 8.869387755102041, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '621626', 'license': 'ADSL', 'n_tokens_mistral': 883, 'n_tokens_neox': 844, 'n_words': 172, 'path': 'model_1_LogisticRegression.ipynb', 'repo_name': 'Trumane12311/machine-learning-challenge', 'size': '2417'}