This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT count(*) FROM t1 INNER JOIN t2 ON t1.a = t2.b; | |
| for t1_row in t1.rows: | |
| for t2_row in t2.rows: | |
| if (t1_row.a = t2_row.a): | |
| output_match() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let hash_table = build_hash_table(t2.rows.a); // build hash table over column a in t2 | |
| for t1_row in t1.rows: | |
| for t2_row in hash_table(t1_row.a): // lookup the corresponding entry for t1’s row | |
| if (t1_row.a = t2_row.a): | |
| output_match() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let hash_table = build_hash_table(t2.rows.a); // build hash table over column a in t2 | |
| for t1_row in t1.rows: | |
| output_match(hash_table(t1_row.a)): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT | |
| tweets.location, | |
| tweets.follower_count as size, | |
| zipcodes.number as color | |
| FROM | |
| tweets | |
| LEFT JOIN zipcodes on ST_Contains(zipcodes.polygon, tweets.location); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let hash_table = build_hash_table(zipcodes.rows.polygon); // build hash table over polygon column | |
| for t1_row in t1.rows: | |
| for t2_row in hash_table(t1_row.point): | |
| if ST_Contains(t2_row.polygon, t1_row.point): | |
| output_match() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with mlflow.start_run(run_name="Random_Forest_Undercount"): | |
| from sklearn.ensemble import RandomForestRegressor | |
| # model parameters | |
| params = {'n_estimators': 1000, 'random_state': 41} | |
| # log model params | |
| for key in params: | |
| mlflow.log_param(key, params[key]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # get predictions | |
| y_pred = RFtree.predict(test_features) | |
| # compute accuracy metric, then log | |
| R2_score = r2_score(test_labels, y_pred) | |
| print("R2_Score: ", R2_score) | |
| mlflow.log_metric("r2", R2_score) | |
| # plot and save plot graphic linked to model run | |
| xgb.plot_importance(gbtree) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select | |
| sum(number_injured) as number_injured, | |
| avg(party_count) as avg_party_count, | |
| b.osm_id | |
| from la_collisions a, | |
| la_street_buffer b | |
| where | |
| st_contains(b.omnisci_geo,st_setsrid(st_point(a.point_x, a.point_y), 4326)) | |
| group by | |
| b.osm_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| select | |
| max(probability) as probability, | |
| b.FID | |
| from | |
| usgs_8ft_flame_length_probability a, | |
| california_building_footprints b | |
| where | |
| ST_Contains(b.defensible_space, a.omnisci_geo) | |
| group by | |
| b.FID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip install pyomnisci |