<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()
df.columns
df= pd.get_dummies(df)
df.head()
df.columns<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 = df[['koi_period', 'koi_time0bk', 'koi_impact', 'koi_duration', 'koi_depth','koi_model_snr']]<jupyter_output><empty_output><jupyter_text>Create a Train Test SplitUse `koi_disposition` for the y values<jupyter_code>X = selected_features
y = df["koi_disposition_CONFIRMED"].values.reshape(-1, 1)
print(X.shape, y.shape)

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, 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 StandardScaler

# Create a StandardScater model and fit it to the training data

X_scaler = StandardScaler().fit(X_train)
y_scaler = StandardScaler().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)<jupyter_output><empty_output><jupyter_text>Train the Model<jupyter_code>from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(X_train_scaled, y_train_scaled)
training_score = model.score(X_train, y_train)
testing_score = model.score(X_test, y_test)
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>Training Data Score: -0.3781723346897432
Testing Data Score: -0.39975965854151285<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.09938603223330775, 'fraction_numerical': 0.016116653875671526, 'mean_word_length': 8.147368421052631, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '660924', 'license': 'RSA-MD', 'n_tokens_mistral': 961, 'n_tokens_neox': 919, 'n_words': 214, 'path': 'starter_code/model_1.ipynb', 'repo_name': 'sadik-20/Machine-Learning-Challenge', 'size': '2606'}