Comments (1)
Hi @achoum
I found this, I think it describes what you are saying
Hope it will be useful to you
Here is a verbose example of 10-cross validation of TF-DF using sklearn.
from sklearn.model_selection import KFold
import numpy as np
accuraties_per_fold = [] # Test accuracy on the individual folds.
# Run a 10-folds cross-validation.
for fold_idx, (train_indices, test_indices) in enumerate(KFold(n_splits=10, shuffle=True).split(all_df)):
print(f"Running fold {fold_idx+1}")
# Extract the training and testing examples.
sub_train_df = all_df.iloc[train_indices]
sub_test_df = all_df.iloc[test_indices]
# Convert the examples into tensorflow datasets.
sub_train_ds = tfdf.keras.pd_dataframe_to_tf_dataset(sub_train_df, label="income")
sub_test_df = tfdf.keras.pd_dataframe_to_tf_dataset(sub_test_df, label="income")
# Train the model.
model = tfdf.keras.GradientBoostedTreesModel()
model.fit(sub_train_ds, verbose=False)
# Evaluate the model.
model.compile(metrics=["accuracy"])
evaluation = model.evaluate(sub_test_df, return_dict=True, verbose=False)
print(f"Evaluation {evaluation}")
accuraties_per_fold.append(evaluation["accuracy"])
print(f"Cross-validated accuracy: {np.mean(accuraties_per_fold)}")
Output:
Evaluation {'loss': 0.0, 'accuracy': 0.8780701756477356}
Running fold 2
Evaluation {'loss': 0.0, 'accuracy': 0.8833333253860474}
Running fold 3
Evaluation {'loss': 0.0, 'accuracy': 0.8841597437858582}
Running fold 4
Evaluation {'loss': 0.0, 'accuracy': 0.8692408800125122}
Running fold 5
Evaluation {'loss': 0.0, 'accuracy': 0.8679245114326477}
Running fold 6
Evaluation {'loss': 0.0, 'accuracy': 0.8639754056930542}
Running fold 7
Evaluation {'loss': 0.0, 'accuracy': 0.8745063543319702}
Running fold 8
Evaluation {'loss': 0.0, 'accuracy': 0.8679245114326477}
Running fold 9
Evaluation {'loss': 0.0, 'accuracy': 0.8609039187431335}
Running fold 10
Evaluation {'loss': 0.0, 'accuracy': 0.8613426685333252}
Cross-validated accuracy: 0.8711381494998932
Credit: @mathieu
from decision-forests.
Related Issues (20)
- Models trained on pure 1's predict 0 HOT 3
- max_vocab_count won't work for CATEGORICAL integerized in tfdf.keras.GradientBoostedTreesModel HOT 5
- Save and load model with tunning in automatic_tuning_colab.ipynb HOT 4
- Symbol not found, but versions are compatible according to the website HOT 4
- Loading a model returns either an untrained model or broken model HOT 1
- Using call_get_leaves inside @tf.function call in ensemble model inherits from tensorflow.keras.Model HOT 10
- no wheels for apple silicon (macos-arm64) HOT 2
- ANE support through coremltools HOT 4
- Can't use both `sample_weight` and `class_weight` at the same time HOT 1
- Is there a method like ydf.load_model() to load model get a instance of tfdf.keras.RandomForestModel? HOT 2
- decision forests tutorial tf_df_in_tf_js code wasn't working for me
- gpu support for layer use HOT 1
- DistributedGradientBoostedTreesModel does not support Ranking task HOT 1
- TF-DF Compatibility with Keras 3? HOT 6
- make_inspector() throws object of type 'NoneType' has no len() when I retrieve TF DF RF model layer in the hybrid model HOT 3
- tfdf 1.9.0 only compatible with tf 2.16.1 which ships Keras 3 HOT 8
- tensorflow-decision-forests 1.5.0 requires tensorflow~=2.13.0, but you have tensorflow 2.16.1 which is incompatible.
- Decision forest documentation link is broken in the Main page HOT 2
- WARNING:root:Failure to load the inference.so custom c++ tensorflow ops
- OOM errors for large datasets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from decision-forests.