Yam Code
Sign up
Login
New paste
Home
Trending
Archive
English
English
Tiếng Việt
भारत
Sign up
Login
New Paste
Browse
import numpy import pandas import statsmodels.api as sm import seaborn import statsmodels.formula.api as smf import matplotlib.pyplot as plt # Đọc dữ liệu csv data = pandas.read_csv('2014and2015CSMdataset.csv', low_memory=False) # Tinh chỉnh câu hỏi nghiên cứu sub1=data[(data['Sequel']>=3) & (data['Sequel']<=7)] recode1 = {"2014":0 ,"2015":1} # Mã hóa biến phân loại theo kiểu nhị phân cho biến Year # M tim thu xem con bien nao qui ve 1 voi 0 duoc khong thay cho bien year recode1 = {"2014":0 ,"2015":1} #ne . No k co y nghia sub1['Year1']= sub1['Year'].map(recode1) sub1['Year1'] = pandas.to_numeric(sub1['Year1'], errors='coerce') data['Likes'] =pandas.to_numeric(data['Likes'], errors='coerce') data['Genre'] = pandas.to_numeric(data['Genre'], errors='coerce') data['Views'] =pandas.to_numeric(data['Views'], errors='coerce') data['Comments'] =pandas.to_numeric(data['Comments'], errors='coerce') data['Sequel'] =pandas.to_numeric(data['Sequel'], errors='coerce') sub1['Year1']= sub1['Year'].map(recode1) # Chuyển sang dữ liệu số sub1['Year1'] = pandas.to_numeric(sub1['Year1'], errors='coerce') # Canh chuẩn biến Comments sub1['Comments_c'] = (sub1['Comments'] - sub1['Comments'].mean()) sub2 = sub1[['Comments_c', 'Year1']].dropna() log_reg = smf.logit(formula = 'Year1 ~ Comments_c', data = sub2).fit() ############'Year1 ~ Comments_c' bien truoc dau "~" phai la dang 0 va 1 nghia la co hoac khong. print(log_reg.summary()) ### Đánh giá mô hình logistic X = sub2['Comments_c'] y = sub2['Year1'] # Chia dữ liệu thành 2 tập: train và test from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=50, shuffle=True) log_reg2 = sm.Logit(y_train, X_train).fit() yhat = log_reg2.predict(X_test) prediction = list(map(round, yhat)) from sklearn.metrics import (confusion_matrix, accuracy_Genre) #confusion_matrix cm = confusion_matrix(y_test, prediction) print ("Confusion Matrix : \n", cm) print('Test accuracy = ', accuracy_Genre(y_test, prediction))
Paste Settings
Paste Title :
[Optional]
Paste Folder :
[Optional]
Select
Syntax Highlighting :
[Optional]
Select
Markup
CSS
JavaScript
Bash
C
C#
C++
Java
JSON
Lua
Plaintext
C-like
ABAP
ActionScript
Ada
Apache Configuration
APL
AppleScript
Arduino
ARFF
AsciiDoc
6502 Assembly
ASP.NET (C#)
AutoHotKey
AutoIt
Basic
Batch
Bison
Brainfuck
Bro
CoffeeScript
Clojure
Crystal
Content-Security-Policy
CSS Extras
D
Dart
Diff
Django/Jinja2
Docker
Eiffel
Elixir
Elm
ERB
Erlang
F#
Flow
Fortran
GEDCOM
Gherkin
Git
GLSL
GameMaker Language
Go
GraphQL
Groovy
Haml
Handlebars
Haskell
Haxe
HTTP
HTTP Public-Key-Pins
HTTP Strict-Transport-Security
IchigoJam
Icon
Inform 7
INI
IO
J
Jolie
Julia
Keyman
Kotlin
LaTeX
Less
Liquid
Lisp
LiveScript
LOLCODE
Makefile
Markdown
Markup templating
MATLAB
MEL
Mizar
Monkey
N4JS
NASM
nginx
Nim
Nix
NSIS
Objective-C
OCaml
OpenCL
Oz
PARI/GP
Parser
Pascal
Perl
PHP
PHP Extras
PL/SQL
PowerShell
Processing
Prolog
.properties
Protocol Buffers
Pug
Puppet
Pure
Python
Q (kdb+ database)
Qore
R
React JSX
React TSX
Ren'py
Reason
reST (reStructuredText)
Rip
Roboconf
Ruby
Rust
SAS
Sass (Sass)
Sass (Scss)
Scala
Scheme
Smalltalk
Smarty
SQL
Soy (Closure Template)
Stylus
Swift
TAP
Tcl
Textile
Template Toolkit 2
Twig
TypeScript
VB.Net
Velocity
Verilog
VHDL
vim
Visual Basic
WebAssembly
Wiki markup
Xeora
Xojo (REALbasic)
XQuery
YAML
HTML
Paste Expiration :
[Optional]
Never
Self Destroy
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Status :
[Optional]
Public
Unlisted
Private (members only)
Password :
[Optional]
Description:
[Optional]
Tags:
[Optional]
Encrypt Paste
(
?
)
Create New Paste
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Site Languages
×
English
Tiếng Việt
भारत