Minor changes to model and Added Results to Presentation Slides

isaac
Pavan Mandava 6 years ago
parent 75055a6ba8
commit 089f883428

@ -212,8 +212,8 @@ def get_sample_weights_with_features(theta_bias: float = None, random_state: int
:return: returns a dictionary of random weights for each feature :return: returns a dictionary of random weights for each feature
""" """
weights = {THETA_BIAS_FEATURE: theta_bias} weights = {THETA_BIAS_FEATURE: theta_bias}
random.seed(random_state)
for feature in FEATURE_LIST: for feature in FEATURE_LIST:
random.seed(random_state)
weights[feature] = round(random.uniform(-1.0, 1.0), 5) weights[feature] = round(random.uniform(-1.0, 1.0), 5)
return weights return weights

@ -177,4 +177,9 @@ class Result:
def print_result(self): def print_result(self):
""" Prints F1 Score""" """ Prints F1 Score"""
print('F1 Score :: ', self.f1_score, ' Label :: ', self.label, ' Average :: ', self.average) print_line = 'F1 Score :: ' + str(self.f1_score)
if self.label:
print_line += ' Label :: ' + self.label
if self.average:
print_line += ' Average :: ' + self.average
print(print_line)

Binary file not shown.

@ -98,7 +98,6 @@ Base Classifier: {\bf {\color{red} Perceptron}}
\item Linear Classifier \item Linear Classifier
\item Binary Classifier \item Binary Classifier
\end{itemize} \end{itemize}
\bigskip
\begin{minted}[autogobble, breaklines,breakanywhere, fontfamily=helvetica, fontsize=\small]{python} \begin{minted}[autogobble, breaklines,breakanywhere, fontfamily=helvetica, fontsize=\small]{python}
class Perceptron: class Perceptron:
@ -112,6 +111,8 @@ class MultiClassPerceptron:
def predict(self, X_test: list) def predict(self, X_test: list)
\end{minted} \end{minted}
\bigskip
- {\bf Parameters} and {\bf Hyperparameters}
\end{frame} \end{frame}
@ -134,6 +135,7 @@ Lexicons and Regular Expressions ($\approx$ 30 Features)
..... .....
} }
\end{minted} \end{minted}
\bigskip
\item REGEX \item REGEX
\begin{itemize} \begin{itemize}
\item $ACRONYM$ \item $ACRONYM$
@ -185,13 +187,13 @@ Lexicons and Regular Expressions ($\approx$ 30 Features)
\begin{tabular}{| l | c | c |} \hline \begin{tabular}{| l | c | c |} \hline
{\bf Averaging} & {\bf Score} \\ {\bf Averaging} & {\bf Score} \\
\hline \hline \hline \hline
MACRO & 0.59 \\ MICRO & 0.64 \\
\hline \hline
MICRO & 0.57 \\ MACRO & 0.57 \\
\hline \hline
background & 0.63 \\ background & 0.72 \\
method & 0.48 \\ method & 0.54 \\
result & 0.55 \\ result & 0.46 \\
\hline \hline
\end{tabular}} \end{tabular}}

@ -18,10 +18,10 @@ labels = set([inst.true_label for inst in X_train_inst])
X_test_inst = read_csv_file(test_file_path, '\t') X_test_inst = read_csv_file(test_file_path, '\t')
# number of training iterations # number of training iterations
epochs = int(len(X_train_inst)*0.9) epochs = int(len(X_train_inst)*1.5)
# create MultiClassPerceptron classifier object # create MultiClassPerceptron classifier object
clf = MultiClassPerceptron(epochs=epochs, learning_rate=0.9, random_state=42) clf = MultiClassPerceptron(epochs=epochs, learning_rate=0.75, random_state=101)
# train the model # train the model
clf.fit(X_train=X_train_inst, labels=list(labels)) clf.fit(X_train=X_train_inst, labels=list(labels))
@ -34,9 +34,9 @@ y_true = [inst.true_label for inst in X_test_inst]
# Model Evaluation # Model Evaluation
f1_score_micro = f1_score(y_true, y_test, labels, const.AVG_MICRO) f1_score_micro = f1_score(y_true, y_test, labels, const.AVG_MICRO)
# f1_score_macro = f1_score(y_true, y_test, labels, const.AVG_MACRO) f1_score_macro = f1_score(y_true, y_test, labels, const.AVG_MACRO)
# f1_score_none = f1_score(y_true, y_test, labels, None) f1_score_none = f1_score(y_true, y_test, labels, None)
# Print F1 Score # Print F1 Score
for result in f1_score_micro: for result in f1_score_micro + f1_score_macro + f1_score_none:
result.print_result() result.print_result()

Loading…
Cancel
Save