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 spacy | |
| from spacy import displacy | |
| # install spacy model | |
| #! pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_md-2.2.0/en_core_web_md-2.2.0.tar.gz | |
| nlp = spacy.load("en_core_web_md") | |
| doc = nlp("I think Barack Obama met founder of Facebook at occasion of a release of a new NLP algorithm.") | |
| displacy.render(doc, style="dep") # (1) | |
| displacy.render(doc, style="ent") # (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
| # import custom modules | |
| import html_file_parsing as hfp | |
| # define listing sources | |
| Tech_Topics=[ | |
| 'https://medium.com/topic/artificial-intelligence', | |
| 'https://medium.com/topic/blockchain', | |
| 'https://medium.com/topic/cryptocurrency', | |
| 'https://medium.com/topic/data-science', | |
| 'https://medium.com/topic/machine-learning', |
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 libraries | |
| from bs4 import BeautifulSoup | |
| import requests | |
| import re | |
| import pandas as pd | |
| import json | |
| class ArticleTable(object): | |
| """From medium page with listing of articles get links and then extract info from each article""" |
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
| from __future__ import unicode_literals, print_function | |
| import re | |
| import spacy | |
| import pandas as pd | |
| from spacy import displacy | |
| import os | |
| from collections import defaultdict | |
| import itertools | |
| import plac | |
| import random |
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
| from evalmodel import test_eval_model | |
| dico, df_metrics = test_eval_model("ner_models/mytrainedmodel", TEST_DATA) |
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 re | |
| from collections import Counter | |
| import spacy | |
| from graph_show import GraphShow | |
| import itertools | |
| from collections import defaultdict | |
| class NewsMining(): |
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
| class GraphShow(): | |
| """"Create demo page""" | |
| def __init__(self): | |
| self.base = ''' | |
| <html> | |
| <head> | |
| <script type="text/javascript" src="VIS/dist/vis.js"></script> | |
| <link href="VIS/dist/vis.css" rel="stylesheet" type="text/css"> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
| </head> |
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
| #ipmort finction from other gists | |
| from entites_graph import NewsMining | |
| from html_file_parsing import ArticleParsing | |
| #imports | |
| import pandas as pd | |
| # set url | |
| url = "https://towardsdatascience.com/cat-dog-or-elon-musk-145658489730" |
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 plotly.io as pio | |
| pio.templates.default = "plotly_white" | |
| from plotly.subplots import make_subplots | |
| import pandas as pd | |
| import plotly.express as px | |
| import matplotlib.pylab as pl | |
| import numpy as np | |
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
| def interaction_plot(col1, col2, interaction_values, background_display, is_cat=True, width=700, height=500,opacity=0.7): | |
| """ | |
| This function plots shap interaction values between two selected columns (col1 & col2), where x axis are values of column 1, y axis are shap interaction values, and hue (color) is the second column. | |
| Args: | |
| col1 (str) : name of the first feature | |
| col2 (str) : name of the second feature | |
| interaction_values (numpy.array) : matrix obtained with shap shap_interaction_values | |
| background_display (pandas.DataFrame) : the original values for background data used in shap explainer | |
| is_cat (bool) : is the col2 a categorical value, True by default |
OlderNewer