Skip to content

Restore compatibility with modern Python, pandas, and TensorFlow#43

Open
victalejo wants to merge 3 commits into
ItamarRocha:masterfrom
victalejo:master
Open

Restore compatibility with modern Python, pandas, and TensorFlow#43
victalejo wants to merge 3 commits into
ItamarRocha:masterfrom
victalejo:master

Conversation

@victalejo
Copy link
Copy Markdown

This pull request updates data handling and model training code to improve compatibility with recent versions of pandas and TensorFlow/Keras, and standardizes model file naming conventions. The main changes focus on replacing deprecated methods, updating optimizer parameters, and ensuring consistency in model file extensions.

Pandas and Data Handling Updates:

  • Replaced the deprecated DataFrame.append() method with pd.concat() in both the get_data_needed and fast_data functions in iq.py, ensuring compatibility with newer pandas versions. [1] [2]
  • Updated the df.drop() call in preprocess_df in training.py to use the axis=1 keyword argument instead of a positional argument, aligning with current pandas best practices.

TensorFlow/Keras and Model Handling Updates:

  • Changed the Adam optimizer initialization in train_data (in training.py) to use the learning_rate parameter instead of the deprecated lr, and removed the unused decay parameter.
  • Updated the ModelCheckpoint callback in train_data to save models with a .keras extension and monitor val_accuracy instead of the deprecated val_acc.
  • Standardized model file naming in testing.py by replacing .model with .keras when loading models, ensuring consistency with the new saving convention. [1] [2]

victalejo and others added 3 commits May 20, 2026 05:08
Pinned versions were ~5 years old and the project no longer installs or
runs on a fresh environment:

- requirements.txt: switch git:// (deprecated by GitHub since 2022) to
  https://, relax pins to numpy>=1.23, pandas>=2.0, tensorflow>=2.13,
  scikit-learn>=1.3 so installs succeed on Python 3.10+
- iq.py: replace DataFrame.append() (removed in pandas 2.0) with
  pd.concat() in get_all_candles and fast_data
- training.py: drop("future", 1) -> drop("future", axis=1) for pandas
  2.x; Adam(lr=, decay=) -> Adam(learning_rate=) (lr kwarg removed,
  decay no longer a constructor arg in Keras 3); val_acc -> val_accuracy
  so the ModelCheckpoint actually saves the best epoch

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ModelCheckpoint in Keras 3 (bundled with TF 2.16+) rejects custom
extensions like .model and requires .keras (whole model) or .weights.h5
(weights only). The previous suffix would have aborted training as soon
as val_accuracy improved.

- training.py:220: "models/{}.model" -> "models/{}.keras"
- testing.py:125, 139: train_data() + '.model' -> + '.keras'

Validated end-to-end with TF 2.16.2: ModelCheckpoint saves on
val_accuracy improvement, load_model() reloads the file, and the
restored model produces valid softmax predictions (339 554 params
preserved).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix: restore compatibility with modern Python/pandas/TensorFlow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant