google-research/timesfm
TimesFM (Time Series Foundation Model) is a pretrained time-series foundation model developed by Google Research for time-series forecasting.
Python★ 31,116+342 that day#7 on trending
7.4%duplicated code · 1,158 of 15,657 lines
48clones in code
61code files of 128 scanned
10.98%duplicated over all files · 134 clones
The code number leaves out tests, fixtures, docs, examples, data files, styles, translations and vendored code.
Largest clones in the code
- 130 lines in 2 placespython1,056 tokens
72class BatchedInContextXRegBase: 73 """Helper class for in-context regression covariate formatting. 74 75 Attributes: 76 targets: List of targets (responses) of the in-context regression. 77 train_lens: List of lengths of each target vector from the context. 78 test_lens: List of lengths of each forecast horizon. 79 train_dynamic_numerical_covariates: Dict of covariate names mapping to the 80 dynamic numerical covariates of each forecast task on the context. Their 81 lengths should match the corresponding lengths in `train_lens`.First 10 of 130 lines.
- 165 lines in 2 placespython777 tokens
207 self.static_numerical_covariates = static_numerical_covariates or {} 208 self.static_categorical_covariates = static_categorical_covariates or {} 209 210def _assert_covariates(self, assert_covariate_shapes: bool = False) -> None: 211 """Verifies the validity of the covariate inputs.""" 212 213 # Check presence. 214 if ( 215 self.train_dynamic_numerical_covariates 216 and not self.test_dynamic_numerical_covariates190 self.static_numerical_covariates = static_numerical_covariates or {} 191 self.static_categorical_covariates = static_categorical_covariates or {} 192 193def _assert_covariates(self, assert_covariate_shapes: bool = False) -> None: 194 """Verifies the validity of the covariate inputs.""" 195 196 # Check presence. 197 if (self.train_dynamic_numerical_covariates and 198 not self.test_dynamic_numerical_covariates) or ( 199 not self.train_dynamic_numerical_covariates andFirst 10 of 165 lines, the second copy on the right.
- 88 lines in 2 placespython626 tokens
377 x_test = [(x_test - x_mean) / x_std] 378 379# Categorical features. Encode one by one. 380one_hot_encoder = preprocessing.OneHotEncoder( 381 drop=one_hot_encoder_drop, 382 sparse_output=False, 383 handle_unknown="ignore", 384) 385for name in sorted(self.train_dynamic_categorical_covariates.keys()): 386 ohe_train = _unnest(self.train_dynamic_categorical_covariates[name])[355 x_test = [np.concatenate(norm_test, axis=0)] 356 357# Categorical features. Encode one by one. 358one_hot_encoder = preprocessing.OneHotEncoder( 359 drop=one_hot_encoder_drop, 360 sparse_output=False, 361 handle_unknown="ignore", 362) 363for name in sorted(self.train_dynamic_categorical_covariates.keys()): 364 ohe_train = _unnest(First 10 of 88 lines, the second copy on the right.
7 more
- 28 lines in 2 placespython265 tokens
- 21 lines in 2 placespython203 tokens
- 26 lines in 2 placespython187 tokens
- 24 lines in 2 placespython186 tokens
- 29 lines in 2 placespython185 tokens
- 17 lines in 2 placespython142 tokens
- 15 lines in 2 placespython141 tokens
Largest clones over all files, tests and data included
- 130 lines in 2 placespython1,056 tokens
72class BatchedInContextXRegBase: 73 """Helper class for in-context regression covariate formatting. 74 75 Attributes: 76 targets: List of targets (responses) of the in-context regression. 77 train_lens: List of lengths of each target vector from the context. 78 test_lens: List of lengths of each forecast horizon. 79 train_dynamic_numerical_covariates: Dict of covariate names mapping to the 80 dynamic numerical covariates of each forecast task on the context. Their 81 lengths should match the corresponding lengths in `train_lens`.First 10 of 130 lines.
- 165 lines in 2 placespython777 tokens
207 self.static_numerical_covariates = static_numerical_covariates or {} 208 self.static_categorical_covariates = static_categorical_covariates or {} 209 210def _assert_covariates(self, assert_covariate_shapes: bool = False) -> None: 211 """Verifies the validity of the covariate inputs.""" 212 213 # Check presence. 214 if ( 215 self.train_dynamic_numerical_covariates 216 and not self.test_dynamic_numerical_covariates190 self.static_numerical_covariates = static_numerical_covariates or {} 191 self.static_categorical_covariates = static_categorical_covariates or {} 192 193def _assert_covariates(self, assert_covariate_shapes: bool = False) -> None: 194 """Verifies the validity of the covariate inputs.""" 195 196 # Check presence. 197 if (self.train_dynamic_numerical_covariates and 198 not self.test_dynamic_numerical_covariates) or ( 199 not self.train_dynamic_numerical_covariates andFirst 10 of 165 lines, the second copy on the right.
- 25 lines in 14 placesjsondocs and examples50 tokenstimesfm-forecasting/examples/global-temperature/output/animation_data.json:2781–2805timesfm-forecasting/examples/global-temperature/output/animation_data.json:3000–3024timesfm-forecasting/examples/global-temperature/output/animation_data.json:3215–3239timesfm-forecasting/examples/global-temperature/output/animation_data.json:3426–3450timesfm-forecasting/examples/global-temperature/output/animation_data.json:3633–3657and 9 more
2781], 2782"historical_values": [ 2783 0.8899999856948853, 2784 0.8899999856948853, 2785 1.0199999809265137, 2786 0.8799999952316284, 2787 0.8500000238418579, 2788 0.8799999952316284, 2789 0.8799999952316284, 2790 0.8999999761581421,First 10 of 25 lines.
- 88 lines in 2 placespython626 tokens
- 26 lines in 13 placesjsondocs and examples51 tokenstimesfm-forecasting/examples/global-temperature/output/animation_data.json:2974–2999timesfm-forecasting/examples/global-temperature/output/animation_data.json:3188–3213timesfm-forecasting/examples/global-temperature/output/animation_data.json:3398–3423timesfm-forecasting/examples/global-temperature/output/animation_data.json:3604–3629timesfm-forecasting/examples/global-temperature/output/animation_data.json:3806–3831and 8 more
By format, code only
| Format | Files | Lines | Clones | Duplicated lines | Duplication |
|---|---|---|---|---|---|
| python | 50 | 14,808 | 48 | 1,158 | 7.82% |
| bash | 10 | 675 | 0 | 0 | 0% |
| perl | 1 | 174 | 0 | 0 | 0% |
By format, all files
| Format | Files | Lines | Clones | Duplicated lines | Duplication |
|---|---|---|---|---|---|
| json | 5 | 6,157 | 74 | 2,110 | 34.27% |
| python | 78 | 20,433 | 57 | 1,238 | 6.06% |
| markdown | 15 | 2,462 | 2 | 14 | 0.57% |
| yaml | 3 | 72 | 1 | 16 | 22.22% |
| bash | 13 | 798 | 0 | 0 | 0% |
| csv | 5 | 358 | 0 | 0 | 0% |
| perl | 1 | 174 | 0 | 0 | 0% |
| toml | 2 | 125 | 0 | 0 | 0% |
| text | 4 | 110 | 0 | 0 | 0% |
| txt | 1 | 49 | 0 | 0 | 0% |
Trending appearances
| Day | Rank | Stars | Files | Lines | Clones | All files | Code | Health | Commit |
|---|---|---|---|---|---|---|---|---|---|
| Sep 5, 2026 | #7 | 31,116 (+342) | 128 | 30,752 | 134 | 10.98% | 7.4% | — | 0df95ae |
| Sep 4, 2026 | #4 | 30,771 (+1,618) | 128 | 30,681 | 133 | 10.99% | 7.4% | — | aa48015 |
| Sep 3, 2026 | #2 | 30,144 (+343) | 128 | 30,681 | 133 | 10.99% | 7.4% | — | aa48015 |
Want this for your own project? Install jscpd and run jscpd ., or measure it the way the baselines were measured.