<jupyter_start><jupyter_text>Baseline- Try to classify investment opportunities (buy/sell) for upcoming IPO- No NLP or fancy models- Raw IPO listing data<jupyter_code>#core
%matplotlib inline
import pandas as pd
import glob
import nasdaq
import ml
from pathlib import Path<jupyter_output><empty_output><jupyter_text>Load NASDAQ IPO Performace<jupyter_code>#load and sort by date priced
df = pd.read_csv('../Datasets/0 ipo listings.csv', index_col='Symbol')
df['Date Priced'] = pd.to_datetime(df['Date Priced'], format='%Y-%m-%d')
df.sort_values(by='Date Priced', inplace=True)
df = df[list(df.columns.drop(['1D', '1W', '1M', '3M'])) + ['1D', '1W', '1M', '3M']]<jupyter_output><empty_output><jupyter_text>Preprocessing<jupyter_code>#transform company name 
df.insert(0, 'Name Length', df['Company Name'].str.len())
df.insert(0, 'Name Words', df['Company Name'].str.split(' ').map(lambda x: len(x)))
df.drop(['Company Name'], axis=1, inplace=True)

#add quarter
df.insert(0, 'Q', df['Date Priced'].map(lambda x: pd.Period(x,'Q').quarter))

#add month
df.insert(0, 'Month', df['Date Priced'].dt.month)

df.drop(['Date Priced'], axis=1, inplace=True)
#encode market
df['Market'] = ml.encode(df, 'Market')
#to one hot encoding
df = pd.concat([pd.get_dummies(df['Market']).add_prefix('MKT'), df], axis=1)
df = pd.concat([pd.get_dummies(df['Month']).add_prefix('M'), df], axis=1)
df = pd.concat([pd.get_dummies(df['Q']).add_prefix('Q'), df], axis=1)
df.drop(['Market', 'Month', 'Q'], axis=1, inplace=True)
df.head(3)
#save for later improvements
df.to_csv('../Datasets/1 baseline.csv', index=True, index_label='Symbol')
#quarter and month
months = df.loc[:, 'Q1':'MKT13'].columns
classes = df.loc[:, '1D':'3M'].columns
others = df.columns.difference(months).difference(classes)

#standardize
df = pd.concat([ml.standardize(df[others]), df[months], df[classes]], axis=1)
#feature importance
indices = ml.show_feature_importance(df, '3M')
#feature selection
df = ml.select_features(indices.shape[0], indices, df)
#as expected the results are poor
ml.run_ml_flow(df)<jupyter_output>C:\Users\Void\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py:106: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
  warnings.warn(message, mplDeprecation, stacklevel=1)
{'fraction_non_alphanumeric': 0.1681800236873273, 'fraction_numerical': 0.013422818791946308, 'mean_word_length': 6.796923076923077, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '383765', 'license': 'MIT', 'n_tokens_mistral': 921, 'n_tokens_neox': 893, 'n_words': 225, 'path': 'Notebooks/1 Baseline.ipynb', 'repo_name': 'algonell/IPOMiner', 'size': '2533'}