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
library(randomForest) | |
library(rpart) | |
library(kernlab) | |
library(nnet) | |
data<-iris | |
ndata<-nrow(data) | |
ridx<-sample(ndata,ndata*0.5) | |
data.learn<-data[ridx,] | |
data.test<-data[-ridx,] |
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
data<-iris | |
data_train<-data[,-5]#5列目はラベルなので削除 | |
km<-kmeans(data_train,3) | |
km$cluster | |
table(data[,5],km$cluster)#本物のラベルとグループ分けを比較 | |
# ----xmeans------ | |
xm<-xmeans(data_train,3) | |
table(data[,5],xm$cluster)#本物のラベルとグループ分けを比較 |
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
##様々な手法で予測精度の比較を行う## | |
##randomForest,SVM,ナイーブベイズ,ニューラルネット | |
library(xgboost) | |
library(caret) | |
library(Matrix) | |
library(kernlab) | |
library(randomForest) | |
library(e1071) | |
library(nnet) | |
library(ggplot2) |
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
library(MASS) | |
seiseki<-read.csv('seiseki.csv') | |
seiseki<-seiseki[c(1:30),] | |
seiseki.ca<-corresp(seiseki,nf=2) | |
biplot(seiseki.ca) |
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
library(conjoint) | |
data(tea)#サンプルデータ | |
#コンジョイント分析用のデータ | |
print(tprof) #各プロファイルの表示 | |
print(tlevn) #各水準 | |
head(tprefm) #効用データ(100人分) | |
Conjoint(tprefm, tprof, tlevn) #コンジョイント分析 |
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
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
#ライブラリーインポート | |
import requests | |
from bs4 import BeautifulSoup | |
from time import sleep | |
#スクレイピング | |
class Scr(): | |
def __init__(self, urls): |
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
import requests | |
from bs4 import BeautifulSoup | |
import sys | |
import MeCab | |
from time import sleep | |
import numpy as np | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
##関数定義 | |
# Step1:URLからテキスト情報をスクレイピング |
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
import sqlite3 | |
dbname = 'trains.db' | |
conn=sqlite3.connect(dbname) | |
c = conn.cursor() | |
# executeメソッドでSQL文を実行する | |
create_table = 'create table toukeilab (id value,name verchar)' | |
c.execute(create_table) |
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
import requests | |
from bs4 import BeautifulSoup | |
import sys | |
import MeCab | |
from time import sleep | |
import numpy as np | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
import sqlite3 | |
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
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
#ライブラリーインポート | |
import requests | |
from bs4 import BeautifulSoup | |
import sys | |
import MeCab | |
from time import sleep | |
import numpy as np | |
from sklearn.feature_extraction.text import TfidfVectorizer |
OlderNewer