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 Faker | |
| from faker import Faker |
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
| #BONUS | |
| #To push your GC plot to Plotly Studio automatically | |
| #!pip install chart_studio | |
| import chart_studio | |
| import chart_studio.plotly as py | |
| username = '#REPLACE YOUR USERNAME HERE#' # your username | |
| api_key = '#REPLACE YOUR API KEY HERE#' # your api key - go to profile > settings > regenerate key | |
| chart_studio.tools.set_credentials_file(username=username, api_key=api_key) | |
| py.plot(fig, filename = 'cmc_treemap', auto_open=True) |
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 --upgrade plotly | |
| import plotly.graph_objects as go | |
| import plotly.express as px | |
| fig = px.treemap(df_final, | |
| path=['name'], | |
| values='USD_market_cap', | |
| color_continuous_scale='RdYlGn', | |
| color='USD_percent_change_24h', | |
| ) |
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
| import matplotlib | |
| import matplotlib.pyplot as plt | |
| #!pip install squarify | |
| import squarify | |
| #load data | |
| sizes=df_final["USD_market_cap"] | |
| label=df_final["name"] | |
| # color scale on the price development |
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
| import pandas as pd | |
| #normalize the data into dataframe format | |
| df = pd.json_normalize(data["data"]) | |
| cols_to_keep = ['name','symbol','cmc_rank','quote.USD.price','quote.USD.percent_change_24h','quote.USD.market_cap',] | |
| df_final = df[cols_to_keep] | |
| #rename columns | |
| df_final.columns = ['name','symbol','cmc_rank','USD_price','USD_percent_change_24h','USD_market_cap',] | |
| #uncomment below to print the table | |
| #df_final |
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
| #This example uses Python 2.7 and the python-request library. | |
| from requests import Request, Session | |
| from requests.exceptions import ConnectionError, Timeout, TooManyRedirects | |
| import json | |
| url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest' | |
| parameters = { | |
| 'start':'1', | |
| 'limit':'10', |
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
| # import initial libraries | |
| from collections import Counter | |
| from sklearn.datasets import make_classification | |
| from imblearn.under_sampling import NearMiss | |
| from matplotlib import pyplot | |
| from numpy import where | |
| # create dataset - imbalanced in the ratio of 90:10 | |
| X, y = make_classification(n_samples=1000, n_features=20, n_redundant=1, | |
| n_clusters_per_class=1, weights=[0.9], flip_y=0.3, random_state=1) | |
| counter = Counter(y) |
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
| # import necessary libraries | |
| import numpy as np | |
| from sklearn.svm import SVC | |
| from imblearn.over_sampling import SMOTE | |
| from imblearn.under_sampling import RandomUnderSampler | |
| from imblearn.pipeline import Pipeline | |
| from sklearn.model_selection import cross_val_score | |
| from sklearn.metrics import roc_auc_score | |
| from numpy import 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
| #PART 1 | |
| # import sampling and other necessary libraries | |
| from collections import Counter | |
| from imblearn.over_sampling import SMOTE | |
| from sklearn.model_selection import train_test_split | |
| import pandas as pd | |
| import numpy as np | |
| import warnings | |
| warnings.simplefilter(action='ignore', category=FutureWarning) | |
| from sklearn.svm import SVC |
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
| #PART 1 | |
| # import SMOTE oversampling and other necessary libraries | |
| from collections import Counter | |
| from imblearn.over_sampling import SMOTE | |
| from sklearn.model_selection import train_test_split | |
| import pandas as pd | |
| import numpy as np | |
| import warnings | |
| warnings.simplefilter(action='ignore', category=FutureWarning) |