text-processing

cell array, add suffix to every string

半世苍凉 提交于 2021-01-27 07:32:04
问题 Suppose I have a cell array containing strings: c = {'foo1', 'foo2', 'foo3'} I now want to add the same suffix " bar " to each string, such that the cell array becomes: c = {'foo1bar', 'foo2bar', 'foo3bar'} Is there a shortcut to doing this, without explicitly looping through each element? 回答1: strcat operates on cell arrays: >> c = {'foo1', 'foo2', 'foo3'} c = 'foo1' 'foo2' 'foo3' >> c2 = strcat(c,'bar') c2 = 'foo1bar' 'foo2bar' 'foo3bar' 回答2: What about using cellfun: c=cellfun(@(x) strcat

cell array, add suffix to every string

旧时模样 提交于 2021-01-27 07:30:23
问题 Suppose I have a cell array containing strings: c = {'foo1', 'foo2', 'foo3'} I now want to add the same suffix " bar " to each string, such that the cell array becomes: c = {'foo1bar', 'foo2bar', 'foo3bar'} Is there a shortcut to doing this, without explicitly looping through each element? 回答1: strcat operates on cell arrays: >> c = {'foo1', 'foo2', 'foo3'} c = 'foo1' 'foo2' 'foo3' >> c2 = strcat(c,'bar') c2 = 'foo1bar' 'foo2bar' 'foo3bar' 回答2: What about using cellfun: c=cellfun(@(x) strcat

Rust vs python program performance results question

ぃ、小莉子 提交于 2021-01-23 07:50:46
问题 I wrote a program that count words. Here is the program use std::collections::HashMap; use std::io; use std::io::prelude::*; #[derive(Debug)] struct Entry { word: String, count: u32, } static SEPARATORS: &'static [char] = &[ ' ', ',', '.', '!', '?', '\'', '"', '\n', '(', ')', '#', '{', '}', '[', ']', '-', ';', ':', ]; fn main() { if let Err(err) = try_main() { if err.kind() == std::io::ErrorKind::BrokenPipe { return; } // Ignore any error that may occur while writing to stderr. let _ =

Rust vs python program performance results question

≡放荡痞女 提交于 2021-01-23 07:49:31
问题 I wrote a program that count words. Here is the program use std::collections::HashMap; use std::io; use std::io::prelude::*; #[derive(Debug)] struct Entry { word: String, count: u32, } static SEPARATORS: &'static [char] = &[ ' ', ',', '.', '!', '?', '\'', '"', '\n', '(', ')', '#', '{', '}', '[', ']', '-', ';', ':', ]; fn main() { if let Err(err) = try_main() { if err.kind() == std::io::ErrorKind::BrokenPipe { return; } // Ignore any error that may occur while writing to stderr. let _ =

Testing text classification ML model with new data fails

旧时模样 提交于 2020-12-23 18:06:03
问题 I have built a machine learning model to classify emails as spams or not. Now i want to test my own email and see the result. So i wrote the following code to classify the new email: message = """Subject: Hello this is from google security team we want to recover your password. Please contact us as soon as possible""" message = pd.Series([message,]) transformed_message = CountVectorizer(analyzer=process_text).fit_transform(message) proba = model.predict_proba(transformed_message)[0] Knowing

Testing text classification ML model with new data fails

北城以北 提交于 2020-12-23 17:59:31
问题 I have built a machine learning model to classify emails as spams or not. Now i want to test my own email and see the result. So i wrote the following code to classify the new email: message = """Subject: Hello this is from google security team we want to recover your password. Please contact us as soon as possible""" message = pd.Series([message,]) transformed_message = CountVectorizer(analyzer=process_text).fit_transform(message) proba = model.predict_proba(transformed_message)[0] Knowing

Testing text classification ML model with new data fails

落爺英雄遲暮 提交于 2020-12-23 17:57:54
问题 I have built a machine learning model to classify emails as spams or not. Now i want to test my own email and see the result. So i wrote the following code to classify the new email: message = """Subject: Hello this is from google security team we want to recover your password. Please contact us as soon as possible""" message = pd.Series([message,]) transformed_message = CountVectorizer(analyzer=process_text).fit_transform(message) proba = model.predict_proba(transformed_message)[0] Knowing

Testing text classification ML model with new data fails

守給你的承諾、 提交于 2020-12-23 17:53:50
问题 I have built a machine learning model to classify emails as spams or not. Now i want to test my own email and see the result. So i wrote the following code to classify the new email: message = """Subject: Hello this is from google security team we want to recover your password. Please contact us as soon as possible""" message = pd.Series([message,]) transformed_message = CountVectorizer(analyzer=process_text).fit_transform(message) proba = model.predict_proba(transformed_message)[0] Knowing

Min-Max Normalization using AWK

雨燕双飞 提交于 2020-08-05 20:01:10
问题 I dont know Why I am unable to loop through all the records. currently it goes for last record and prints the normalization for it. Normalization formula: New_Value = (value - min[i]) / (max[i] - min[i]) Program { for(i = 1; i <= NF; i++) { if (min[i]==""){ min[i]=$i;} #initialise min if (max[i]==""){ max[i]=$i;} #initialise max if ($i<min[i]) { min[i]=$i;} #new min if ($i>max[i]) { max[i]=$i;} #new max } } END { for(j = 1; j <= NF; j++) { normalized_value[j] = ($j - min[j])/(max[j] - min[j])