Path: blob/main/ch08/logistic-regression-bag-of-words/log-reg-iterative.ipynb
1944 views
Kernel: Python 3 (ipykernel)
Logistic Regression Classifier for Text with Iterative Training
Requires fewer computate resource when used with massive datasets compared to log-reg.ipynb.
Obtaining the IMDb movie review dataset
In [1]:
In [2]:
Preprocessing the movie dataset into more convenient format
Install pyprind by uncommenting the next code cell.
In [3]:
In [4]:
Out[4]:
0% [##############################] 100% | ETA: 00:00:00
Total time elapsed: 00:00:19
Shuffling the DataFrame:
In [5]:
Optional: Saving the assembled data as CSV file:
In [6]:
In [7]:
Out[7]:
In [8]:
Out[8]:
(50000, 2)
Training a logistic regression model for document classification
Working with bigger data - online algorithms and out-of-core learning
In [9]:
In [10]:
In [11]:
Out[11]:
('"In 1974, the teenager Martha Moxley (Maggie Grace) moves to the high-class area of Belle Haven, Greenwich, Connecticut. On the Mischief Night, eve of Halloween, she was murdered in the backyard of her house and her murder remained unsolved. Twenty-two years later, the writer Mark Fuhrman (Christopher Meloni), who is a former LA detective that has fallen in disgrace for perjury in O.J. Simpson trial and moved to Idaho, decides to investigate the case with his partner Stephen Weeks (Andrew Mitchell) with the purpose of writing a book. The locals squirm and do not welcome them, but with the support of the retired detective Steve Carroll (Robert Forster) that was in charge of the investigation in the 70\'s, they discover the criminal and a net of power and money to cover the murder.<br /><br />""Murder in Greenwich"" is a good TV movie, with the true story of a murder of a fifteen years old girl that was committed by a wealthy teenager whose mother was a Kennedy. The powerful and rich family used their influence to cover the murder for more than twenty years. However, a snoopy detective and convicted perjurer in disgrace was able to disclose how the hideous crime was committed. The screenplay shows the investigation of Mark and the last days of Martha in parallel, but there is a lack of the emotion in the dramatization. My vote is seven.<br /><br />Title (Brazil): Not Available"',
1)
In [12]:
In [13]:
In [14]:
In [15]:
Out[15]:
0% [##############################] 100% | ETA: 00:00:00
Total time elapsed: 00:00:17
In [16]:
Out[16]:
Accuracy: 0.868