-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tom Theile
committed
Aug 23, 2019
1 parent
5eaf7e1
commit d2df9ce
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
import pandas as pd | ||
import numpy as np | ||
import pickle | ||
from keras.preprocessing.text import Tokenizer | ||
from keras.models import Sequential | ||
from keras.layers import Activation, Dense, Dropout | ||
#from sklearn.preprocessing import LabelBinarizer | ||
#import sklearn.datasets as skds | ||
from pathlib import Path | ||
|
||
|
||
|
||
# For reproducibility | ||
np.random.seed(1237) | ||
|
||
# Source file directory | ||
path_train = "U:\\data\\wos_bib_random_nastates.csv" | ||
|
||
files_train = skds.load_files(path_train,load_content=False) | ||
|
||
label_index = files_train.target | ||
label_names = files_train.target_names | ||
labelled_files = files_train.filenames | ||
|
||
data_tags = ["filename","category","news"] | ||
data_list = [] | ||
|
||
# Read and add data from file to a list | ||
i=0 | ||
for f in labelled_files: | ||
data_list.append((f,label_names[label_index[i]],Path(f).read_text())) | ||
i += 1 | ||
|
||
# We have training data available as dictionary filename, category, data | ||
data = pd.DataFrame.from_records(data_list, columns=data_tags) |