Skip to content

Commit

Permalink
Add save and load variables functionality to data pre-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
PauloHFS committed Oct 1, 2024
1 parent 94fc939 commit 382c534
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ Data pre-processing is a crucial step in the data analysis process. It involves
3. Data standardization: Normalize the data to a common scale to make it easier to compare.
4. Data transformation: Convert categorical data into numerical values using techniques like one-hot encoding.
5. Introduction of models validation: Split the data into training and testing sets to evaluate the model's performance.

How to save the vars in a file and load them later:

```python
import pickle

# Save the variables to a file
with open('vars.pkl', 'wb') as f:
pickle.dump([X_train, X_test, y_train, y_test], f)

# Load the variables from a file
with open('vars.pkl', 'rb') as f:
X_train, X_test, y_train, y_test = pickle.load(f)
```
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ from sklearn.model_selection import train_test_split

# Split the data into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
```
```

0 comments on commit 382c534

Please sign in to comment.