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
| # ESERCIZIO 1 | |
| for uid, iid in purchases_set: | |
| row = user_indices[uid] | |
| col = item_indices[iid] | |
| purchases[row, col] = 1 | |
| # ESERCIZIO 2 |
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
| # ESERCIZIO 1 | |
| # 1a | |
| with open("items.csv", "r") as f: | |
| items = {int(iid): name for iid, name in csv.reader(f, delimiter=";")} | |
| # 1b | |
| len(items) | |
| # 1c |
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
| #!/bin/bash | |
| # TODO: | |
| # - start, stop, status commands | |
| # - jupyterlab option | |
| # - pass settings (e.g. profile) to aws cli | |
| PROGNAME=$(basename $0) | |
| AWS="aws" | |
| OPEN="xdg-open" |
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
| # jq script to convert output of list-resource-record-sets into valid input for change-resource-record-sets | |
| # NS and SOA records are removed | |
| # based on https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-migrating.html | |
| # (aliases and domain name change are not handled) | |
| .ResourceRecordSets|map(select(.Type!="NS" and .Type!="SOA")|{"Action":"CREATE","ResourceRecordSet":.})|{"Changes":.} |
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
| # ESERCIZIO 1 | |
| # 1a | |
| model_a = LinearRegression() | |
| model_a.fit(X_train, y_train) | |
| print_eval(X_val, y_val, model_a) | |
| pd.Series(model_a.coef_, index=X.columns) | |
| # 1b |
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
| # ESERCIZIO 1 | |
| # 1a | |
| lrm = LinearRegression() | |
| summer_X_train = summer_train[["temp"]] | |
| summer_y_train = summer_train["demand"] | |
| lrm.fit(summer_X_train, summer_y_train) | |
| # 1b | |
| print_eval(summer_X_train, summer_y_train, lrm) |
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
| # ESERCIZIO 1 | |
| # 1a | |
| data_summer.describe() | |
| # 1b | |
| data_summer["temp"].plot.hist(bins=20); | |
| data_summer["demand"].plot.hist(bins=20); | |
| # 1c |
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
| # ESERCIZIO 1 | |
| # 1a | |
| tips.loc[0, "size"] | |
| # 1b | |
| tips.loc[tips["total_bill"].idxmax()] | |
| # 1c | |
| tips["tip"].mean() |
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
| # ESERCIZIO 1 | |
| # 1a | |
| population[4] | |
| # 1b | |
| states[-3:] | |
| # 1c | |
| population[states == "Florida"] |
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
| # SOLUZIONE 1 | |
| for uid, iid in purchases_set: | |
| row = user_indices[uid] | |
| col = item_indices[iid] | |
| purchases[row, col] = 1 | |
| # SOLUZIONE 2a | |
| # per ogni coppia ID, nome | |
| for uid, name in users.items(): |