机器学习1k近邻

自己一直学习计算机视觉方面的东西,现在想学习一下数据挖掘跟搜索引擎,自己基础也有点薄弱,看朱明的那本数据挖掘,只能片面的了解这个数据挖掘。不过最近有一本书 机器学习实战,于是乎通过实战的形式了解一下基本的算法的执行过程。
在算法当中,很多都是相通的,模式识别、机器学习、数据挖掘、自然语言处理等等这些算法归结起来其实差不了多少,题外话不多说了,好好学习。

k近邻算法

对于这个算法,我用自己的话来描述一下,就是把一个未知数与所有已有的数据样本求距离,对距离进行排序,取前k个数,这k这个数中,那个类别多,那这个未知数就属于哪个类别。

不用说,大家也知道这个k的选取还是很重要的。先用书上最简单的例子表述一下。

# -*- coding: utf-8 -*
from numpy import *
import operatordef createDataSet():group = array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1]])labels = ['A','A','B','B']return group, labelsdef classify0(inX, dataSet, labels, k):#行的个数也就是训练集的个数dataSetSize = dataSet.shape[0]print ('dataSetSize:',dataSetSize)#tile表示将输入向量inX在行方向上重复dataSetSize次,在列的方向上重复1次,具体就是构建一个跟训练集对应的数组大小,相减就是为了求距离diffMat = tile(inX,(dataSetSize,1)) - dataSetprint('diffMat:',diffMat)sqDiffMat = diffMat**2print('sqDiffMat:',sqDiffMat)#sum默认axis=0为普通相加,axis=1为矩阵的每一个行向量相加sqDistances = sqDiffMat.sum(axis=1)print('sqDistances:',sqDistances)distances = sqDistances**0.5print('distances:',distances)sortedDistIndicies = distances.argsort()print('sortedDistIndicies:',sortedDistIndicies)#定义一个词典classCount={}#range(k) 为[0,1,2....k-1]print('labels:',labels)for i in range(k):       voteIlabel = labels[sortedDistIndicies[i]]#获得最小的k个长度#get 返回键值key对应的值;如果key没有在字典里,则返回default参数的值,这边default是0,功能计算每个标签类别的个数classCount[voteIlabel] = classCount.get(voteIlabel,0) + 1#sorted 排序是产生一个新的列表,sort是在原有基础上排序,key按第一个域进行排序,Ture为逆序print('classCount:',classCount)sortedClassCount = sorted(classCount.iteritems(),key=operator.itemgetter(1),reverse=True)print('sortedClassCount:',sortedClassCount)return sortedClassCount[0][0]

这边我已经将要解释的地方标识了。

下面就是运行,运行结果如下:

   1:  >>> import kNN
   2:  >>> group,labels = kNN.createDataSet()
   3:  >>> kNN.classify0([0,0],group,labels,3)
   4:  ('dataSetSize:', 4L)
   5:  ('diffMat:', array([[-1. , -1.1],
   6:         [-1. , -1. ],
   7:         [ 0. ,  0. ],
   8:         [ 0. , -0.1]]))
   9:  ('sqDiffMat:', array([[ 1.  ,  1.21],
  10:         [ 1.  ,  1.  ],
  11:         [ 0.  ,  0.  ],
  12:         [ 0.  ,  0.01]]))
  13:  ('sqDistances:', array([ 2.21,  2.  ,  0.  ,  0.01]))
  14:  ('distances:', array([ 1.48660687,  1.41421356,  0.        ,  0.1       ]))
  15:  ('sortedDistIndicies:', array([2, 3, 1, 0], dtype=int64))
  16:  ('labels:', ['A', 'A', 'B', 'B'])
  17:  ('classCount:', {'A': 1, 'B': 2})
  18:  ('sortedClassCount:', [('B', 2), ('A', 1)])
  19:  'B'

对照这个结果看上面的代码应该都能够看懂。

好,跟书上说得一样,这个例子没有实际的用处,于是书上给出了两个实际的例子。一个是使用k-近邻算法改进约会网站的配对效果。

算法过程,如书中:

image

这个例子给出了机器学习的一般过程

首先我们要知道我们要做什么,知道要做什么之后,我们要采集数据,数据采集完了之后,我们要将数据进行预处理。

1、因为我们采集过来的数据,可能面临杂乱、重复、不完整等等原因,常见处理方法有数据集成、数据清洗、数据变换、数据归约。

对于本例,认为数据是有效的,我们处理是数据变换,将数据变成分类器可以识别的格式。数据归约将数据同一化,不然数据值大的就相当于权重大了,对处理有影响。

定义一个函数将文本转换为数组

   1:  def file2matrix(filename):
   2:      fr = open(filename)
   3:      arrayOLines = fr.readlines()
   4:      numberOfLines = len(arrayOLines)
   5:      print('numberOfLines:',numberOfLines)
   6:      returnMat = zeros((numberOfLines,3))
   7:      print('returnMat:',returnMat)
   8:      classLabelVector = []
   9:      index = 0
  10:      for line in arrayOLines:
  11:          #没有传入参数时,是默认去除首尾空格
  12:          line = line.strip()
  13:          listFromLine = line.split('\t')
  14:          returnMat[index,:] = listFromLine[0:3]
  15:          classLabelVector.append(int(listFromLine[-1]))
  16:          index += 1
  17:      print('returnMat:',returnMat)
  18:      print('classLabelVector:',classLabelVector[0:20])
  19:      return returnMat,classLabelVector
  20:          

运行结果如下:

   1:  >>> reload(kNN)
   2:  <module 'kNN' from 'E:\Machine Learning\exercise\ch02\kNN.py'>
   3:  >>> datingDataMat,datingLabels = kNN.file2matrix('datingTestSet.txt')
   4:  ('numberOfLines:', 1000)
   5:  ('returnMat:', array([[ 0.,  0.,  0.],
   6:         [ 0.,  0.,  0.],
   7:         [ 0.,  0.,  0.],
   8:         ..., 
   9:         [ 0.,  0.,  0.],
  10:         [ 0.,  0.,  0.],
  11:         [ 0.,  0.,  0.]]))
  12:  ('returnMat:', array([[  4.09200000e+04,   8.32697600e+00,   9.53952000e-01],
  13:         [  1.44880000e+04,   7.15346900e+00,   1.67390400e+00],
  14:         [  2.60520000e+04,   1.44187100e+00,   8.05124000e-01],
  15:         ..., 
  16:         [  2.65750000e+04,   1.06501020e+01,   8.66627000e-01],
  17:         [  4.81110000e+04,   9.13452800e+00,   7.28045000e-01],
  18:         [  4.37570000e+04,   7.88260100e+00,   1.33244600e+00]]))
  19:  ('classLabelVector:', [3, 2, 1, 1, 1, 1, 3, 3, 1, 3, 1, 1, 2, 1, 1, 1, 1, 1, 2, 3])

在我们进行模型选择的时候,我们可以通过图形化数据的方式,这样我们可以根据一定的经验就知道应该使用什么样的模型。

我们通过Matplotlib来显示图像,这个包的安装,直接下载这个包就可以了,如果提示你缺少什么包,补齐就好了。

根据作者使用,我们画出玩视频游戏所消耗的时间百分比 与每周所消费的冰淇淋公升数

   1:  >>> import matplotlib
   2:  >>> import matplotlib.pyplot as plt
   3:  >>> fig = plt.figure()
   4:  >>> ax = fig.add_subplot(111)//这边111表示把绘图区域分成1行*1列共1个区域,然后在区域1上创建一个轴对象
   5:  >>> ax.scatter(datingDataMat[:,1],datingDataMat[:,2])//scatter表示散点图
   6:  <matplotlib.collections.PathCollection object at 0x00000000064DD128>
   7:  >>> plt.show()

image

对于这个图很难看出有用的东西,用颜色进行标识,如下图:

   1:  ax.scatter(datingDataMat[:,1],datingDataMat[:,2],15.0*array(datingLabels),15.0*array(datingLabels))

image

换一下属性,x轴用每年获取的飞行常客里程数表示,则三类分的就比较明显了。

image

下面就是归一化,不归一化,值大的相当于权重就大,而权重的大小是应该我们去添加的,不是由值的大小来

对于归一化,我们一般有三种处理方法。

1、[(原值-最小值)/(最大值-最小值)]*(新的最大值-新的最小值)+新的最小值。

2、(原值-均值)/标准差

3、小数的规范化,就是移动小数点位,归化到0-1之间

我们就采用的是第一种方式,这边我们新的最大值是1,最小值是0.我们的归一化就是:

[(原值-最小值)/(最大值-最小值)]

   1:  def autoNorm(dataSet):
   2:      minVals = dataSet.min(0)
   3:      maxVals = dataSet.max(0)
   4:      print('minVals:',minVals)
   5:      print('maxVals:',maxVals)
   6:      ranges = maxVals - minVals
   7:      normDataSet = zeros(shape(dataSet))
   8:      m = dataSet.shape[0]
   9:      print('m:',m)
  10:      normDataSet = dataSet - tile(minVals,(m,1))
  11:      normDataSet = normDataSet/tile(ranges,(m,1))
  12:      return normDataSet,ranges,minVals
  13:      

执行结果

   1:  >>> reload(kNN)
   2:  <module 'kNN' from 'E:\Machine Learning\exercise\ch02\kNN.py'>
   3:  >>> normMat,ranges,minVals = kNN.autoNorm(datingDataMat)
   4:  ('minVals:', array([ 0.      ,  0.      ,  0.001156]))
   5:  ('maxVals:', array([  9.12730000e+04,   2.09193490e+01,   1.69551700e+00]))
   6:  ('m:', 1000L)
   7:  >>> normMat
   8:  array([[ 0.44832535,  0.39805139,  0.56233353],
   9:         [ 0.15873259,  0.34195467,  0.98724416],
  10:         [ 0.28542943,  0.06892523,  0.47449629],
  11:         ..., 
  12:         [ 0.29115949,  0.50910294,  0.51079493],
  13:         [ 0.52711097,  0.43665451,  0.4290048 ],
  14:         [ 0.47940793,  0.3768091 ,  0.78571804]])
  15:  >>> ranges
  16:  array([  9.12730000e+04,   2.09193490e+01,   1.69436100e+00])
  17:  >>> minVals
  18:  array([ 0.      ,  0.      ,  0.001156])

为了评估算法,我们将数据分成训练集和测试集,通常用70%的数据作为训练集,用剩下30%的数据作为测试集。很重要的一点是训练集和测试集均要含有各种类型的数据,通常我们要对数据进行“洗牌”,然后再分成训练集和测试集。

下面进行测试

   1:  def datingClassTest():
   2:      hoRatio = 0.10
   3:      datingDataMat,datingLabels = file2matrix('datingTestSet.txt')
   4:      normMat,ranges,minVals = autoNorm(datingDataMat)
   5:      m = normMat.shape[0]
   6:      numTestVecs = int(m*hoRatio)
   7:      errorCount = 0.0
   8:      for i in range(numTestVecs):
   9:          #这边的意思是拿前10%的数据作为测试,后90%的数据是训练样本
  10:          classifierResult = classify0(normMat[i,:],normMat[numTestVecs:m,:],datingLabels[numTestVecs:m],5)
  11:          print "the classifier came back with:%d,the real answer is: %d" %(classifierResult,datingLabels[i])
  12:          if(classifierResult !=datingLabels[i]):
  13:              errorCount +=1.0
  14:      print "the total error rate is :%f" %(errorCount/float(numTestVecs))

得到的结果

   1:  >>> import kNN
   2:  >>> kNN.datingClassTest()
   3:  the classifier came back with:3,the real answer is: 3
   4:  the classifier came back with:2,the real answer is: 2
   5:  the classifier came back with:1,the real answer is: 1
   6:  。。。。。。
   7:  the classifier came back with:3,the real answer is: 3
   8:  the classifier came back with:3,the real answer is: 3
   9:  the classifier came back with:2,the real answer is: 2
  10:  the classifier came back with:2,the real answer is: 1
  11:  the classifier came back with:1,the real answer is: 1
  12:  the total error rate is :0.040000

这个结果还好,我这边设置的k为5,k的变化结果也会变化,所有怎么选择这个k也是值得研究的。

最后为了适合系统的使用变得直观一点,写下如下函数:

   1:  def classifyPerson():
   2:      resultList = ['not at all','in small doses','in large doses']
   3:      percentTats = float(raw_input("percentage of time spent playing video games?"))
   4:      ffMiles = float(raw_input("frequent flier miles earned per year?"))
   5:      iceCream = float(raw_input("liters of ice cream consumed per year?"))
   6:      datingDataMat,datingLabels = file2matrix('datingTestSet.txt')
   7:      normMat,ranges,minVals = autoNorm(datingDataMat)
   8:      inArr = array([ffMiles,percentTats,iceCream])
   9:      classifierResult = classify0((inArr-minVals)/ranges,normMat,datingLabels,3)
  10:      #这边减1是由于最后分类的数据是1,2,3对应到数组中是0,1,2
  11:      print "You will probably like this person: ",resultList[classifierResult -1]

运行结果如下:

   1:  >>> import kNN
   2:  >>> kNN.classifyPerson()
   3:  percentage of time spent playing video games?11
   4:  frequent flier miles earned per year?11111
   5:  liters of ice cream consumed per year?0.6
   6:  You will probably like this person:  in large doses
   7:  >>> kNN.classifyPerson()
   8:  percentage of time spent playing video games?10
   9:  frequent flier miles earned per year?10000
  10:  liters of ice cream consumed per year?0.5
  11:  You will probably like this person:  in small doses

下一个demo是手写识别系统,书中为了简化只设别0-9的数字。

作者这边是将图像数据转化成向量

写下如下函数:

   1:  #把图像文本数据存入returnVect
   2:  def img2vector(filename):
   3:      #图像像素是32*32
   4:      returnVect = zeros((1,1024))
   5:      fr = open(filename)
   6:      for i in range(32):
   7:          lineStr = fr.readline()
   8:          for j in range(32):
   9:              returnVect[0,32*i+j] = int(lineStr[j])
  10:      return returnVect

运行查看如下:

   1:  >>> import kNN
   2:  >>> kNN.img2vector('testDigits/0_13.txt')
   3:  array([[ 0.,  0.,  0., ...,  0.,  0.,  0.]])
   4:  >>> testVector  = kNN.img2vector('testDigits/0_13.txt')
   5:  >>> testVector[0,0:31]
   6:  array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
   7:          0.,  1.,  1.,  1.,  1.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,
   8:          0.,  0.,  0.,  0.,  0.])

分类函数已经有,下面就是测试模型

   1:  def handwritingClassTest():
   2:      hwLabels = []
   3:      #获取文件目录
   4:      trainingFileList = listdir('trainingDigits')
   5:      m = len(trainingFileList)
   6:      trainingMat = zeros((m,1024))
   7:      for i in range(m):
   8:          fileNameStr = trainingFileList[i]
   9:          #得到数组如[0_12,txt],[0]是第一个数据0_12
  10:          fileStr = fileNameStr.split('.')[0]
  11:          #得到数组如[0,12]获得第一个数[0],从这边看出文件名还是有很大作用的。
  12:          classNumStr = int(fileStr.split('_')[0])
  13:          hwLabels.append(classNumStr)
  14:          trainingMat[i,:] = img2vector('trainingDigits/%s' % fileNameStr)
  15:      testFileList = listdir('testDigits')     
  16:      errorCount = 0.0
  17:      mTest = len(testFileList)
  18:      for i in range(mTest):
  19:          fileNameStr = testFileList[i]
  20:          fileStr = fileNameStr.split('.')[0]   
  21:          classNumStr = int(fileStr.split('_')[0])
  22:          vectorUnderTest = img2vector('testDigits/%s' % fileNameStr)
  23:          classifierResult = classify0(vectorUnderTest, trainingMat, hwLabels, 3)
  24:          print "the classifier came back with: %d, the real answer is: %d" % (classifierResult, classNumStr)
  25:          if (classifierResult != classNumStr): errorCount += 1.0
  26:      print "\nthe total number of errors is: %d" % errorCount
  27:      print "\nthe total error rate is: %f" % (errorCount/float(mTest))

最后得到的结果

   1:  >>> import kNN
   2:  >>> kNN.handwritingClassTest()
   3:  the classifier came back with: 0, the real answer is: 0
   4:  the classifier came back with: 0, the real answer is: 0
   5:  。。。。。。
   6:  the classifier came back with: 9, the real answer is: 9
   7:  the classifier came back with: 9, the real answer is: 9
   8:  the classifier came back with: 9, the real answer is: 9
   9:  the classifier came back with: 9, the real answer is: 9
  10:   
  11:  the total number of errors is: 11
  12:   
  13:  the total error rate is: 0.011628

错误率还是很低的,这个模型是可行的。最后作者给出k近邻算法的不足。k近邻算法必须保存全部数据集,训练集大的话,占用存储空间大,由于要对每个数据计算距离是浮点型计算,计算量大。

另外相似性的判断是根据欧式距离来的,这样如果计算欧式距离的属性中如果有无关属性或者噪音数据比较多的话,那这个测量的距离就不是真正的距离,误差较大。解决办法有给重要属性的权重加大。

刚学习Python,主要以看代码,自己照着敲代码,思考了一下整个思路,了解了基本的Python语法。

下面继续学习决策树。

转载于:https://www.cnblogs.com/fengbing/p/3514503.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/376137.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql服务器的线程数查看方法_MySQL服务器线程数的查看方法详解

本文实例讲述了MySQL服务器线程数的查看方法。&#xff0c;具体如下&#xff1a;mysql重启命令&#xff1a;/etc/init.d/mysql restartMySQL服务器的线程数需要在一个合理的范围之内&#xff0c;这样才能保证MySQL服务器健康平稳地运行。Threads_created表示创建过的线程数&…

[No000003]现代版三十六计,计计教你如何做人

《现代版三十六计,计计教你如何做人》 …………………………………………………………………………………… 第1计施恩计 在人际交往中,见到给人帮忙的机会,要立马扑上去,像一只饥饿的松鼠扑向地球上的最后一粒松籽. 因为人情就是财富,人际关系一个最基本的目的就是结人情,有人…

mysql 重置root密码 远程访问_重置mysql的root密码以及设置mysql远程登陆权限

root密码忘记&#xff0c;重置mysql的root密码&#xff1a;t一、修改mysql的配置文件my.cnf1.在[mysqld]的段中加上一句&#xff1a;skip-grant-tables[mysqld]datadir/var/lib/mysqlsocket/var/lib/mysql/mysql.sockskip-name-resolveskip-grant-tables保存并且退出vi。(或执行…

C#中枚举类型和int类型的转化

先定义一个枚举类型 public enum PropertyType { 小学 0, 初中, 高中&#xff0c;大学 }; int ->enum int d2; PropertyType a(PropertyType)d; int <- enum PropertyType d PropertyType.小学; int a Convert.ToInt32(d); Enum类有关的方法 E…

vagrant使用centos的环境安装..

vagrant这货挺好用的..简要就是, 下好virtualbox, vagrant, 然后下个你需要的box. 然后vagrant box add boxname boxpath就行. 然后在合适的地方vagrant init就能创建好虚拟机, 然后vagrant up是开启, vagrant ssh是通过ssh连接过去, 可以装一个zsh , 配置oh my zsh啥的, 然后安…

linux mysql odbc驱动安装_MySQL ODBC 驱动安装

阅读目录一、在线安装1、yum在线安装驱动2、配置驱动3、测试连接二、编译安装1、MySQL创建测试用户和测试库2、安装驱动3、配置驱动4、测试一、在线安装1、yum在线安装驱动# yum -y installunixODBC#yum -y install mysql-connector-odbc2、配置驱动(1)查看驱动程序相关信息# c…

通过 HTTPS 和 SSL 确保 Windows Azure 网站 (WAWS) 安全

编辑人员注释&#xff1a;本文章由 Windows Azure 网站团队的项目经理 Erez Benari 撰写。 随着身份盗窃和各种形式的网络犯罪迅速增多&#xff0c;使用安全套接字层 (SSL) 对网站进行保护变得越来越重要和普遍。如果将网站托管在 Windows Azure 网站 (WAWS) 上&#xff0c;您可…

mysql之多表查询

今天在项目中遇到一个数据库查询的问题&#xff1a;三张表分别放置不同的东西&#xff1a;分享的音频相关数据、分享的文字图片说说、分享的主题相关数据。所有分享的东西都可看做新鲜事&#xff0c;现在要求从这三张表将相同的几个字段的数据全部查找出来按照发布时间先后排序…

设立SharePoint2010列表的项目级权限

设置SharePoint2010列表的项目级权限 在SharePoint2010中我们经常会用到这样的权限设置&#xff0c;在一个列表中可以存储多个人输入的数据&#xff0c;但每个人只能看到自己的那部分数据。也就是多个人共同维护一个列表&#xff0c;但各自只能查看、编辑、删除自己录入的那部分…

MySQL优化filler值_MySQL 性能优化神器 Explain 使用分析

简介MySQL 提供了一个 EXPLAIN 命令, 它可以对 SELECT 语句进行分析, 并输出 SELECT 执行的详细信息, 以供开发人员针对性优化.EXPLAIN 命令用法十分简单, 在 SELECT 语句前加上 Explain 就可以了, 例如:EXPLAIN SELECT * from user_info WHERE id < 300;准备为了接下来方便…

Codeforces Round #224 (Div. 2)

题目&#xff1a;http://codeforces.com/contest/382 A Ksenia and Pan Scales 一个求天平是否能够平衡的题目。。。水题,注意一下结果的输出就行。 1 #include <iostream>2 #include <cstdio>3 #include <cstring>4 #include <cstdlib>5 #include <…

二叉树第i层中的所有结点_讲透学烂二叉树(二):图中树的定义amp;各类型树的特征分析...

日常中我们见到的二叉树应用有&#xff0c;Java集合中的TreeSet和TreeMap&#xff0c;C STL中的set、map&#xff0c;以及Linux虚拟内存的管理&#xff0c;以及B-Tree&#xff0c;B-Tree在文件系统&#xff0c;都是通过红黑树去实现的。虽然之前写过《再谈堆排序&#xff1a;堆…

node-webkit 开发环境搭建

node-webkit支持的操作系统类型&#xff1a; Linunx:32bit / 64bitWindows: win32Mac:32bit,10.7 开发环境 1&#xff0c;根据自己的操作系统下载响应的nw二进制文件&#xff0c;下载地址&#xff1a;https://github.com/rogerwang/node-webkit 2,建立基本开发目录&#xff0c;…

mysql sqlsugar_.net core +mysqlSugar(最为简单的增删改查)

首先建立.net Core API - empty 这个就不说了然后创建新的Controller记得添加路由[Route("api/Users")]然后在Nuget Packages安装 所需安装包这里是用mysql所以下载如下的mysqlSugarCore(切记不要忘记安装Mysql.Data)创建实例化class文件DbText.cs用于连接数据库&…

关于eclipse的indigo版中文注释时字体太小的问题(转)

eclipse目前最新版代号indigo, 在win7上使用时中文注释时字体太小的问题. 为什么会这样? 首先我们应该知道, 在win7系统中, font是有"显示"和"隐藏" 状态的. 默认情况下, eclipse使用的默认字体courier new是处于 "隐藏"下的. 这样当eclipse打开…

webdriver(python)学习笔记七——多层框架定位与智能等待

多层框架或窗口定位&#xff1a; switch_to_frame()switch_to_window()智能等待&#xff1a; implicitly_wait()现在web应用中经常会遇到框架如&#xff08;frame&#xff09;或窗口&#xff08;windows&#xff09;的应用&#xff0c;这样定位就比较难&#xff0c;有时定位一个…

bbp代码python_如何正确计算加密债券价格的BBP(Bollinger波段百分比)?

我试图用这个代码计算python中的BBP(Bollinger频带百分比)。然而&#xff0c;我的^{cd1>}函数返回^{{cd2>}或^{cd3>}用于^{cd4>}。当我使用一些硬币收盘价时&#xff0c;令人困惑的是&#xff0c;这个函数返回正确的^{cd4>}数字(而不是inf)。这是我的python代码…

ASP.NET学习路线图

转自&#xff1a;http://www.cnblogs.com/huangmeimujin/archive/2011/08/08/2131242.html 如果你已经有较多的面向对象开发经验&#xff0c;跳过以下这两步&#xff1a; 第一步 掌握一门.NET面向对象语言&#xff0c;C#或VB.NET 我强烈反对在没系统学过一门面向对象(OO)语言的…

centos 多个mysql数据库_CentOS6.5 一台服务器同时安装多个Mysql数据库

建用户与组groupadd mysqluseradd -g mysql mysql下载源码&#xff1a;wget https://downloads.mariadb.org/interstitial/mariadb-10.1.10/source/mariadb-10.1.10.tar.gztar -xvf mariadb-10.1.10.tar.gz1、编译&#xff1a;cmake . -DCMAKE_INSTALL_PREFIX/var/lib/mysql33…

MVC3学习 一 ViewBag和Html.Raw

ViewBag类似于JavaScript的语法&#xff0c;在赋值时动态赋值&#xff0c;比如ViewBag.Dog“哈哈” &#xff0c;这样就会创建一个ViewBag.Dog的对象&#xff0c;供前端页面调用。 在调用时&#xff0c;前台页面用razor方式&#xff0c;ViewBag 直接使用。 public class HomeCo…