161 KiB
161 KiB
In [1]:
from util_lda import LDAUtilClass
from util_bert import BertUtilClass
from util_nlp import NLPTools
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pdC:\Users\NES\anaconda3\envs\collab_paper_dec21\lib\site-packages\gensim\similarities\__init__.py:15: UserWarning: The gensim.similarities.levenshtein submodule is disabled, because the optional Levenshtein package <https://pypi.org/project/python-Levenshtein/> is unavailable. Install Levenhstein (e.g. `pip install python-Levenshtein`) to suppress this warning. warnings.warn(msg) [nltk_data] Downloading package wordnet to [nltk_data] C:\Users\NES\AppData\Roaming\nltk_data... [nltk_data] Package wordnet is already up-to-date! [nltk_data] Downloading package stopwords to [nltk_data] C:\Users\NES\AppData\Roaming\nltk_data... [nltk_data] Package stopwords is already up-to-date! [nltk_data] Downloading package punkt to [nltk_data] C:\Users\NES\AppData\Roaming\nltk_data... [nltk_data] Package punkt is already up-to-date!
In [27]:
nlp_tools = NLPTools()importing english phrases...
C:\Users\NES\AppData\Local\Temp/ipykernel_12908/3999215048.py:1: DtypeWarning: Columns (0) have mixed types.Specify dtype option on import or set low_memory=False. nlp_tools = NLPTools()
importing german phrases...
In [28]:
# %%
talako_project = "Taxi vehicles are particularly suitable for electrification due to their potentially long waiting periods at taxi stops. However, existing charging solutions for electric vehicles require taxi drivers to manually initiate and stop the charging process by connecting and disconnecting a charging cable to a charging station. This makes the use of electric vehicles in taxi operations cumbersome and impractical. The goal of the project is the development of a modular inductive charging solution for electric vehicles that is suitable for taxi operations in public spaces. To validate the solution, the project will deploy a prototype system in a private space and a pilot system in a public space. Within the project, the Networked Embedded Systems group is responsible for the development of a camera-based positioning system that enables taxi drivers to optimally position their cars on the charging system. The goal thereby is to maximize the efficiency factor of the charging solution without complex mechanical solutions that align the inductive charging plates otherwise."
In [29]:
test= []
test.append(talako_project)
test_corpus = nlp_tools.nlp_pipeline_en(test)In [3]:
df = pd.read_csv("zlv_pubs.csv")
df_collabs = pd.read_csv("zlv_pubs_collabs.csv")In [4]:
SAMPLE_SIZE = 20
THRESHOLD_SIZE = 5
KEEP_DUPLICATES = False
MIN_TOPICS= 5In [15]:
test = ["team_building", "nanoparticles", "nanotechnology"]
test_corpus = []
test_corpus.append(test)
In [24]:
lda_instance = LDAUtilClass([60,60,60], df, KEEP_DUPLICATES, SAMPLE_SIZE, THRESHOLD_SIZE, df_collabs)
lda_models = lda_instance.calculate_return_model()-----------initializing testing (test/test set) sequence-------- -----------splitting datasets in test/trainsets-------- -----------building LDA models from training corpus(s)-------- -----------assigning top n topics to every record and normalizing--------
0%| | 0/887 [00:00<?, ?it/s]
0%| | 0/822 [00:00<?, ?it/s]
0%| | 0/1709 [00:00<?, ?it/s]
In [30]:
df_cm = lda_instance.generate_collabs_projects(lda_models["en"],THRESHOLD_SIZE,test_corpus)0%| | 0/595 [00:00<?, ?it/s]
In [34]:
df[df["institute_code"] == 43]["institute"].values[0]Out [34]:
'Umweltmikrobiologie und Biotechnologie'
In [93]:
column_maxes = df_cm.max()
df_max = column_maxes.max()
column_mins = df_cm.min()
df_min = column_mins.min()
normalized_df = (df_cm - df_min) / (df_max - df_min)In [95]:
plt.figure(figsize = (10,8))
sns.heatmap(normalized_df)
sns.set(font_scale=1.5)
plt.xticks(rotation=0)
plt.yticks(rotation=0) Out [95]:
(array([ 0.5, 2.5, 4.5, 6.5, 8.5, 10.5, 12.5, 14.5, 16.5, 18.5, 20.5,
22.5, 24.5, 26.5, 28.5, 30.5, 32.5, 34.5, 36.5, 38.5, 40.5]),
[Text(0, 0.5, '0'),
Text(0, 2.5, '2'),
Text(0, 4.5, '6'),
Text(0, 6.5, '9'),
Text(0, 8.5, '11'),
Text(0, 10.5, '13'),
Text(0, 12.5, '15'),
Text(0, 14.5, '17'),
Text(0, 16.5, '19'),
Text(0, 18.5, '21'),
Text(0, 20.5, '24'),
Text(0, 22.5, '26'),
Text(0, 24.5, '28'),
Text(0, 26.5, '31'),
Text(0, 28.5, '34'),
Text(0, 30.5, '36'),
Text(0, 32.5, '38'),
Text(0, 34.5, '40'),
Text(0, 36.5, '42'),
Text(0, 38.5, '44'),
Text(0, 40.5, '46')])In [10]:
test= []
test.append(talako_project)
test_corpus = nlp_tools.nlp_pipeline_en(test)
# %%
model = lda_models["en"]["model"]
dic = lda_models["en"]["dic"]
topic_df = lda_models["en"]["topic_df"]
In [15]:
topics = model[dic.doc2bow(test_corpus[0])]
topics.sort(key=lambda x: x[1], reverse= True)In [22]:
topic_df = lda_models["en"]["topic_df"]In [22]:
[tp[0] for tp in topics[:10]]Out [22]:
[59, 3, 38, 0, 45, 14, 49, 32, 28, 6]
In [20]:
# %%
for i, topic in enumerate(topics):
wp = lda_models["en"]["model"].show_topic(topic[0])
topic_keywords = ", ".join([word for word, prop in wp])
print(topic[0], topic[1])
print(topic_keywords)
print("institute:", {topic_df.loc[topic_df["Dominant_topic"] == topic[0]]["institute_code"].values[0]})
print("institute:", {topic_df.loc[topic_df["Dominant_topic"] == topic[0]]["institute"].values[0]})
print("paper:" , topic_df.loc[topic_df["Dominant_topic"] == topic[0]]["_source.title"].values[0])
print("________________________")59 0.113346346
photonic, condition, millimeter_wave, mathematics, assisted, coherent, transition, picture, relay, electric
institute: {39.0}
institute: {'Optoelektronik'}
paper: E-band (71-76 GHz) wireless link using compact modules
________________________
3 0.09199181
energy, employing, regulation, outcome, suspension, software, evidence, planning, relationship, travelling_wave
institute: {6.0}
institute: {'Eingebettete Systeme der Informatik'}
paper: Using field-programmable gate arrays for learning non player characters
________________________
38 0.066298135
concept, primary, activity, programme, nonlinear, within, stress, unknown, incentive, sustainable
institute: {41.0}
institute: {'Psychologische Forschungsmethoden – Medienbasierte Wissenskonstruktion'}
paper: Comparing effects of two collaboration scripts on learning activities for wiki-based environments
________________________
0 0.062044848
social, strategy, quality, time, work, health_insurance, broadband, experience, international, view
institute: {6.0}
institute: {'Eingebettete Systeme der Informatik'}
paper: Using field-programmable gate arrays for learning non player characters
________________________
45 0.059036825
structure, field, considering, ultra_wideband, gaas, multiple, antenna, thermoelectric, beamforming, surface
institute: {17.0}
institute: {'Fakultät für Ingenieurwissenschaften / Abt. Elektrotechnik und Informationstechnik'}
paper: Positioning in wireless communications systems: localization with UWB signals
________________________
14 0.057289798
research, learner, europe, introduction, self, stroke, setting, risk, implication, theory
institute: {45.0}
institute: {'WiWi / IBES'}
paper: Evaluating pharmaceutical costs of patients with chronic lung disease in German in- and outpatient setting.: ISPOR 2nd Annual European Congress. 11.-13. Nov.
________________________
49 0.056922045
sulfolobus, sensor, factor, contribution, solfataricus, transport, acidocaldarius, conflict, source, problem
institute: {47.0}
institute: {'Zentrum für BrennstoffzellenTechnik ZBT GmbH'}
paper: A sensitive and selective graphene/cobalt tetrasulfonated phthalocyanine sensor for detection of dopamine
________________________
32 0.056823
teacher, competence, performance, teaching, secondary, training, driver, resource, vocational, professional
institute: {11.0}
institute: {'Fakultät Geisteswissenschaften'}
paper: Further students. Further teachers!: Innovation of school and teacher training curricula given the challenges of current geomedia
________________________
28 0.039217737
market, network, oriented, induced, price, text, modulators, product, elastic, supporting
institute: {39.0}
institute: {'Optoelektronik'}
paper: Integration of Heterostructure Bipolartransistors with Electroabsorption Waveguide Modulators and Applications
________________________
6 0.038810737
approach, transmission, robot, multi, review, technical, quantum, robust, instruction, smart
institute: {17.0}
institute: {'Fakultät für Ingenieurwissenschaften / Abt. Elektrotechnik und Informationstechnik'}
paper: Positioning in wireless communications systems: localization with UWB signals
________________________
46 0.03801208
tool, power, space, combining, optimized, mode, reserve, semi, mapping, action
institute: {37.0}
institute: {'Mechatronik'}
paper: Suitability of driving simulators as a tool to study driving fatigue due to vibration and environment: A review
________________________
25 0.032138765
classification, uncertainty, policy, response, choice, degradation, automotive, protocol, company, service
institute: {31.0}
institute: {'Institut für Schiffstechnik, Meerestechnik und Transportsysteme'}
paper: Prediction of Extreme Ship Responses Using Potential Flow and RANSE Codes
________________________
50 0.03107269
chromatography, liquid, mass_spectrometry, estimation, isotope_ratio, study, mechanism, interface, modified, coupled
institute: {45.0}
institute: {'WiWi / IBES'}
paper: Individualised medicine in the diagnosis and prognosis of patients younger than 65 years with normal karyotype acute myeloid leukemia: a systematic review and meta–analysis of the impact of fms–related tyrosine kinase 3 internal tandem duplication (FLT3-ITD)
________________________
17 0.025741529
case, object, production, coupling, risk_adjustment, chip, reasoning, cooperating, intelligent, solid
institute: {45.0}
institute: {'WiWi / IBES'}
paper: Evaluating pharmaceutical costs of patients with chronic lung disease in German in- and outpatient setting.: ISPOR 2nd Annual European Congress. 11.-13. Nov.
________________________
34 0.022559457
modelling, environment, cost, testbed, grid, contaminant, nanocrystalline, determinant, patient, moment
institute: {41.0}
institute: {'Psychologische Forschungsmethoden – Medienbasierte Wissenskonstruktion'}
paper: Comparing effects of two collaboration scripts on learning activities for wiki-based environments
________________________
10 0.02161361
quantum_dots, self_assembled, nanoparticles, proceeding, road, size, graph, improvement, push, reduction
institute: {39.0}
institute: {'Optoelektronik'}
paper: Heterostructure Semiconductor Photonic Devices and Systems
________________________
53 0.020763293
ship, awareness, group, vibration, numerical, integrating, wave, resistance, experimental_investigation, structure
institute: {31.0}
institute: {'Institut für Schiffstechnik, Meerestechnik und Transportsysteme'}
paper: Prediction of Extreme Ship Responses Using Potential Flow and RANSE Codes
________________________
15 0.02049643
data, decision, efficient, high, wireless_sensor_networks, selection, optimal, coherent_radio, fiber, link
institute: {24.0}
institute: {'Geisteswissenschaften / Germanistik-Linguistik'}
paper: Premise Selection in the Naproche System
________________________
26 0.020357484
context, characteristic, archaeon, modulation, role, assignment, preference, boron, prognostic, question
institute: {41.0}
institute: {'Psychologische Forschungsmethoden – Medienbasierte Wissenskonstruktion'}
paper: Comparing effects of two collaboration scripts on learning activities for wiki-based environments
________________________
24 0.019568948
integrated, modeling, band, module, adaptive, photonic, reliability, photodetectors, vision, optimization
institute: {39.0}
institute: {'Optoelektronik'}
paper: E-band (71-76 GHz) wireless link using compact modules
________________________
23 0.019548008
comparison, component, improved, screening, cost_effectiveness, analytical, european, geomedia, effectiveness, inquiry
institute: {45.0}
institute: {'WiWi / IBES'}
paper: Cost-Effectiveness of screening for glaucoma by opticians in Germany.
________________________
5 0.019547813
control, health, economics, free, cavitation, social, conference, health_insurance, effect, european
institute: {37.0}
institute: {'Mechatronik'}
paper: Suitability of driving simulators as a tool to study driving fatigue due to vibration and environment: A review
________________________
31 0.019544678
application, fiber, radio, type, wireless, therapy, health_care, combination, diversity, four
institute: {17.0}
institute: {'Fakultät für Ingenieurwissenschaften / Abt. Elektrotechnik und Informationstechnik'}
paper: Opportunistic space-time coding to exploit cooperative diversity in fast-fading channels
________________________
37 0.019448612
student, role, support, digital, university, mobile, relation, reflection, game, designing
institute: {11.0}
institute: {'Fakultät Geisteswissenschaften'}
paper: Further students. Further teachers!: Innovation of school and teacher training curricula given the challenges of current geomedia
________________________
58 0.016576128
dynamic, economic, patient, optical, sorption, behavior, survival, liver, evaluating, electricity_market
institute: {45.0}
institute: {'WiWi / IBES'}
paper: Criteria and procedures for determining benefit packages in health care: A comparative perspective
________________________
In [7]:
# %%
talako_project = "Taxi vehicles are particularly suitable for electrification due to their potentially long waiting periods at taxi stops. However, existing charging solutions for electric vehicles require taxi drivers to manually initiate and stop the charging process by connecting and disconnecting a charging cable to a charging station. This makes the use of electric vehicles in taxi operations cumbersome and impractical. The goal of the project is the development of a modular inductive charging solution for electric vehicles that is suitable for taxi operations in public spaces. To validate the solution, the project will deploy a prototype system in a private space and a pilot system in a public space. Within the project, the Networked Embedded Systems group is responsible for the development of a camera-based positioning system that enables taxi drivers to optimally position their cars on the charging system. The goal thereby is to maximize the efficiency factor of the charging solution without complex mechanical solutions that align the inductive charging plates otherwise."
In [8]:
test_corpus = []
test_corpus.append(talako_project)In [6]:
bert_instance = BertUtilClass([60,60,60], df, MIN_TOPICS, KEEP_DUPLICATES, SAMPLE_SIZE, THRESHOLD_SIZE, df_collabs)
bert_models = bert_instance.calculate_return_model()-----------initializing testing (test/test set) sequence-------- -----------splitting datasets in test/trainsets-------- -----------building BERT models from training corpus(s)-------- -----------assigning top n topics to every record and normalizing--------
0%| | 0/887 [00:00<?, ?it/s]
0%| | 0/822 [00:00<?, ?it/s]
0%| | 0/1709 [00:00<?, ?it/s]
In [107]:
topics, similarities = bert_models["en"]["model"].find_topics(talako_project, top_n=10)In [109]:
topicsOut [109]:
[38, 3, 45, 52, 30, 54, 4, 50, 14, 8]
In [111]:
bert_models["en"]["model"].get_topic(38)Out [111]:
[('power_management', 0.15777965430629046),
('multi_source', 0.1306982838468549),
('hybrid', 0.12966378701099496),
('powertrain', 0.10838812971040679),
('fuel_cell', 0.09686554259421014),
('electric_vehicles', 0.09032344142533899),
('drive', 0.08527469704375906),
('hybrid_electric_vehicles', 0.08490680516056615),
('optimal_power', 0.06764021210162854),
('vehicle', 0.054168790858148845)]In [39]:
df_cm_bert = bert_instance.generate_collabs_projects(bert_models["en"],THRESHOLD_SIZE,test_corpus)0%| | 0/132 [00:00<?, ?it/s]
In [52]:
df[df["institute"].str.contains("Verteilte")]["institute_code"].values[0]Out [52]:
44
In [56]:
df[df["institute_code"] == 21]["institute"].values[0]Out [56]:
'Fakultät für Physik, Experimentalphysik'
In [57]:
df[df["institute_code"] == 27]["institute"].values[0]Out [57]:
'IngWi, Maschinenbau, IPE, Transportsysteme und -logistik'
In [58]:
df[df["institute_code"] == 31]["institute"].values[0]Out [58]:
'Institut für Schiffstechnik, Meerestechnik und Transportsysteme'
In [59]:
df[df["institute_code"] == 37]["institute"].values[0]Out [59]:
'Mechatronik'
In [96]:
plt.figure(figsize = (10,8))
sns.set(font_scale=1.5)
sns.heatmap(df_cm_bert)
plt.xticks(rotation=0)
plt.yticks(rotation=0) Out [96]:
(array([ 0.5, 2.5, 4.5, 6.5, 8.5, 10.5, 12.5, 14.5, 16.5, 18.5, 20.5,
22.5, 24.5, 26.5, 28.5, 30.5, 32.5, 34.5, 36.5, 38.5, 40.5]),
[Text(0, 0.5, '0'),
Text(0, 2.5, '2'),
Text(0, 4.5, '6'),
Text(0, 6.5, '9'),
Text(0, 8.5, '11'),
Text(0, 10.5, '13'),
Text(0, 12.5, '15'),
Text(0, 14.5, '17'),
Text(0, 16.5, '19'),
Text(0, 18.5, '21'),
Text(0, 20.5, '24'),
Text(0, 22.5, '26'),
Text(0, 24.5, '28'),
Text(0, 26.5, '31'),
Text(0, 28.5, '34'),
Text(0, 30.5, '36'),
Text(0, 32.5, '38'),
Text(0, 34.5, '40'),
Text(0, 36.5, '42'),
Text(0, 38.5, '44'),
Text(0, 40.5, '46')])In [78]:
column_maxes = df_cm.max()
df_max = column_maxes.max()
column_mins = df_cm.min()
df_min = column_mins.min()
normalized_df = (df_cm - df_min) / (df_max - df_min)
In [104]:
plt.figure(figsize = (10,8))
sns.set(font_scale=2)
sns.heatmap(normalized_df, xticklabels = 5, yticklabels = 5)
plt.xticks(rotation=0)
plt.yticks(rotation=0) Out [104]:
(array([ 0.5, 5.5, 10.5, 15.5, 20.5, 25.5, 30.5, 35.5, 40.5]), [Text(0, 0.5, '0'), Text(0, 5.5, '8'), Text(0, 10.5, '13'), Text(0, 15.5, '18'), Text(0, 20.5, '24'), Text(0, 25.5, '30'), Text(0, 30.5, '36'), Text(0, 35.5, '41'), Text(0, 40.5, '46')])
In [84]:
column_maxes = df_cm_bert.max()
df_max = column_maxes.max()
column_mins = df_cm_bert.min()
df_min = column_mins.min()
normalized_df_bert = (df_cm_bert - df_min) / (df_max - df_min)
In [105]:
plt.figure(figsize = (10,8))
sns.set(font_scale=2)
sns.heatmap(normalized_df_bert,xticklabels = 5, yticklabels = 5)
plt.xticks(rotation=0)
plt.yticks(rotation=0) Out [105]:
(array([ 0.5, 5.5, 10.5, 15.5, 20.5, 25.5, 30.5, 35.5, 40.5]), [Text(0, 0.5, '0'), Text(0, 5.5, '8'), Text(0, 10.5, '13'), Text(0, 15.5, '18'), Text(0, 20.5, '24'), Text(0, 25.5, '30'), Text(0, 30.5, '36'), Text(0, 35.5, '41'), Text(0, 40.5, '46')])