書寫自動智慧:探索Python文本分類器的開發與應用:支持二分類、多分類、多標簽分類、多層級分類和Kmeans聚類

書寫自動智慧:探索Python文本分類器的開發與應用:支持二分類、多分類、多標簽分類、多層級分類和Kmeans聚類

文本分類器,提供多種文本分類和聚類算法,支持句子和文檔級的文本分類任務,支持二分類、多分類、多標簽分類、多層級分類和Kmeans聚類,開箱即用。python3開發。

  • Classifier支持算法

    • LogisticRegression
    • Random Forest
    • Decision Tree
    • K-Nearest Neighbours
    • Naive bayes
    • Xgboost
    • Support Vector Machine(SVM)
    • TextCNN
    • TextRNN
    • Fasttext
    • BERT
  • Cluster

    • MiniBatchKmeans

While providing rich functions, pytextclassifier internal modules adhere to low coupling, model adherence to inert loading, dictionary publication, and easy to use.

  • 安裝
  • Requirements and Installation
pip3 install torch # conda install pytorch
pip3 install pytextclassifier

or

git clone https://github.com/shibing624/pytextclassifier.git
cd pytextclassifier
python3 setup.py install

1. English Text Classifier

包括模型訓練、保存、預測、評估等

examples/lr_en_classification_demo.py:

import syssys.path.append('..')
from pytextclassifier import ClassicClassifierif __name__ == '__main__':m = ClassicClassifier(output_dir='models/lr', model_name_or_model='lr')# ClassicClassifier support model_name:lr, random_forest, decision_tree, knn, bayes, svm, xgboostprint(m)data = [('education', 'Student debt to cost Britain billions within decades'),('education', 'Chinese education for TV experiment'),('sports', 'Middle East and Asia boost investment in top level sports'),('sports', 'Summit Series look launches HBO Canada sports doc series: Mudhar')]# train and save best modelm.train(data)# load best model from model_dirm.load_model()predict_label, predict_proba = m.predict(['Abbott government spends $8 million on higher education media blitz'])print(f'predict_label: {predict_label}, predict_proba: {predict_proba}')test_data = [('education', 'Abbott government spends $8 million on higher education media blitz'),('sports', 'Middle East and Asia boost investment in top level sports'),]acc_score = m.evaluate_model(test_data)print(f'acc_score: {acc_score}')

output:

ClassicClassifier instance (LogisticRegression(fit_intercept=False), stopwords size: 2438)
predict_label: ['education'], predict_proba: [0.5378236358492112]
acc_score: 1.0

2. Chinese Text Classifier(中文文本分類)

文本分類兼容中英文語料庫。

example examples/lr_classification_demo.py

import syssys.path.append('..')
from pytextclassifier import ClassicClassifierif __name__ == '__main__':m = ClassicClassifier(output_dir='models/lr-toy', model_name_or_model='lr')# 經典分類方法,支持的模型包括:lr, random_forest, decision_tree, knn, bayes, svm, xgboostdata = [('education', '名師指導托福語法技巧:名詞的復數形式'),('education', '中國高考成績海外認可 是“狼來了”嗎?'),('education', '公務員考慮越來越吃香,這是怎么回事?'),('sports', '圖文:法網孟菲爾斯苦戰進16強 孟菲爾斯怒吼'),('sports', '四川丹棱舉行全國長距登山挑戰賽 近萬人參與'),('sports', '米蘭客場8戰不敗國米10年連勝'),]m.train(data)print(m)# load best model from model_dirm.load_model()predict_label, predict_proba = m.predict(['福建春季公務員考試報名18日截止 2月6日考試','意甲首輪補賽交戰記錄:米蘭客場8戰不敗國米10年連勝'])print(f'predict_label: {predict_label}, predict_proba: {predict_proba}')test_data = [('education', '福建春季公務員考試報名18日截止 2月6日考試'),('sports', '意甲首輪補賽交戰記錄:米蘭客場8戰不敗國米10年連勝'),]acc_score = m.evaluate_model(test_data)print(f'acc_score: {acc_score}')  # 1.0#### train model with 1w dataprint('-' * 42)m = ClassicClassifier(output_dir='models/lr', model_name_or_model='lr')data_file = 'thucnews_train_1w.txt'm.train(data_file)m.load_model()predict_label, predict_proba = m.predict(['順義北京蘇活88平米起精裝房在售','美EB-5項目“15日快速移民”將推遲'])print(f'predict_label: {predict_label}, predict_proba: {predict_proba}')

output:

ClassicClassifier instance (LogisticRegression(fit_intercept=False), stopwords size: 2438)
predict_label: ['education' 'sports'], predict_proba: [0.5, 0.598941806741534]
acc_score: 1.0
------------------------------------------
predict_label: ['realty' 'education'], predict_proba: [0.7302956923617372, 0.2565005445322923]

3.可解釋性分析

例如,顯示模型的特征權重,以及預測詞的權重 examples/visual_feature_importance.ipynb

import syssys.path.append('..')
from pytextclassifier import ClassicClassifier
import jiebatc = ClassicClassifier(output_dir='models/lr-toy', model_name_or_model='lr')
data = [('education', '名師指導托福語法技巧:名詞的復數形式'),('education', '中國高考成績海外認可 是“狼來了”嗎?'),('sports', '圖文:法網孟菲爾斯苦戰進16強 孟菲爾斯怒吼'),('sports', '四川丹棱舉行全國長距登山挑戰賽 近萬人參與'),('sports', '米蘭客場8戰不敗國米10年連勝')
]
tc.train(data)
import eli5infer_data = ['高考指導托福語法技巧國際認可','意甲首輪補賽交戰記錄:米蘭客場8戰不敗國米10年連勝']
eli5.show_weights(tc.model, vec=tc.feature)
seg_infer_data = [' '.join(jieba.lcut(i)) for i in infer_data]
eli5.show_prediction(tc.model, seg_infer_data[0], vec=tc.feature,target_names=['education', 'sports'])

output:

4. Deep Classification model

本項目支持以下深度分類模型:FastText、TextCNN、TextRNN、Bert模型,import模型對應的方法來調用:

from pytextclassifier import FastTextClassifier, TextCNNClassifier, TextRNNClassifier, BertClassifier

下面以FastText模型為示例,其他模型的使用方法類似。

4.1 FastText 模型

訓練和預測FastText模型示例examples/fasttext_classification_demo.py

import syssys.path.append('..')
from pytextclassifier import FastTextClassifier, load_dataif __name__ == '__main__':m = FastTextClassifier(output_dir='models/fasttext-toy')data = [('education', '名師指導托福語法技巧:名詞的復數形式'),('education', '中國高考成績海外認可 是“狼來了”嗎?'),('education', '公務員考慮越來越吃香,這是怎么回事?'),('sports', '圖文:法網孟菲爾斯苦戰進16強 孟菲爾斯怒吼'),('sports', '四川丹棱舉行全國長距登山挑戰賽 近萬人參與'),('sports', '米蘭客場8戰不敗保持連勝'),]m.train(data, num_epochs=3)print(m)# load trained best modelm.load_model()predict_label, predict_proba = m.predict(['福建春季公務員考試報名18日截止 2月6日考試','意甲首輪補賽交戰記錄:米蘭客場8戰不敗國米10年連勝'])print(f'predict_label: {predict_label}, predict_proba: {predict_proba}')test_data = [('education', '福建春季公務員考試報名18日截止 2月6日考試'),('sports', '意甲首輪補賽交戰記錄:米蘭客場8戰不敗國米10年連勝'),]acc_score = m.evaluate_model(test_data)print(f'acc_score: {acc_score}')  # 1.0#### train model with 1w dataprint('-' * 42)data_file = 'thucnews_train_1w.txt'm = FastTextClassifier(output_dir='models/fasttext')m.train(data_file, names=('labels', 'text'), num_epochs=3)# load best trained model from model_dirm.load_model()predict_label, predict_proba = m.predict(['順義北京蘇活88平米起精裝房在售','美EB-5項目“15日快速移民”將推遲'])print(f'predict_label: {predict_label}, predict_proba: {predict_proba}')x, y, df = load_data(data_file)test_data = df[:100]acc_score = m.evaluate_model(test_data)print(f'acc_score: {acc_score}')

4.2 BERT 類模型

4.2.1 多分類模型

訓練和預測BERT多分類模型,示例examples/bert_classification_zh_demo.py

import syssys.path.append('..')
from pytextclassifier import BertClassifierif __name__ == '__main__':m = BertClassifier(output_dir='models/bert-chinese-toy', num_classes=2,model_type='bert', model_name='bert-base-chinese', num_epochs=2)# model_type: support 'bert', 'albert', 'roberta', 'xlnet'# model_name: support 'bert-base-chinese', 'bert-base-cased', 'bert-base-multilingual-cased' ...data = [('education', '名師指導托福語法技巧:名詞的復數形式'),('education', '中國高考成績海外認可 是“狼來了”嗎?'),('education', '公務員考慮越來越吃香,這是怎么回事?'),('sports', '圖文:法網孟菲爾斯苦戰進16強 孟菲爾斯怒吼'),('sports', '四川丹棱舉行全國長距登山挑戰賽 近萬人參與'),('sports', '米蘭客場8戰不敗國米10年連勝'),]m.train(data)print(m)# load trained best model from model_dirm.load_model()predict_label, predict_proba = m.predict(['福建春季公務員考試報名18日截止 2月6日考試','意甲首輪補賽交戰記錄:米蘭客場8戰不敗國米10年連勝'])print(f'predict_label: {predict_label}, predict_proba: {predict_proba}')test_data = [('education', '福建春季公務員考試報名18日截止 2月6日考試'),('sports', '意甲首輪補賽交戰記錄:米蘭客場8戰不敗國米10年連勝'),]acc_score = m.evaluate_model(test_data)print(f'acc_score: {acc_score}')# train model with 1w data file and 10 classesprint('-' * 42)m = BertClassifier(output_dir='models/bert-chinese', num_classes=10,model_type='bert', model_name='bert-base-chinese', num_epochs=2,args={"no_cache": True, "lazy_loading": True, "lazy_text_column": 1, "lazy_labels_column": 0, })data_file = 'thucnews_train_1w.txt'# 如果訓練數據超過百萬條,建議使用lazy_loading模式,減少內存占用m.train(data_file, test_size=0, names=('labels', 'text'))m.load_model()predict_label, predict_proba = m.predict(['順義北京蘇活88平米起精裝房在售','美EB-5項目“15日快速移民”將推遲','恒生AH溢指收平 A股對H股折價1.95%'])print(f'predict_label: {predict_label}, predict_proba: {predict_proba}')

PS:如果訓練數據超過百萬條,建議使用lazy_loading模式,減少內存占用

4.2.2 多標簽分類模型

分類可以分為多分類和多標簽分類。多分類的標簽是排他的,而多標簽分類的所有標簽是不排他的。

多標簽分類比較直觀的理解是,一個樣本可以同時擁有幾個類別標簽,
比如一首歌的標簽可以是流行、輕快,一部電影的標簽可以是動作、喜劇、搞笑等,這都是多標簽分類的情況。

訓練和預測BERT多標簽分類模型,示例examples/bert_multilabel_classification_zh_demo.py.py

import sys
import pandas as pdsys.path.append('..')
from pytextclassifier import BertClassifierdef load_jd_data(file_path):"""Load jd data from file.@param file_path: format: content,其他,互聯互通,產品功耗,滑輪提手,聲音,APP操控性,呼吸燈,外觀,底座,制熱范圍,遙控器電池,味道,制熱效果,衣物烘干,體積大小@return: """data = []with open(file_path, 'r', encoding='utf-8') as f:for line in f:line = line.strip()if line.startswith('#'):continueif not line:continueterms = line.split(',')if len(terms) != 16:continueval = [int(i) for i in terms[1:]]data.append([terms[0], val])return dataif __name__ == '__main__':# model_type: support 'bert', 'albert', 'roberta', 'xlnet'# model_name: support 'bert-base-chinese', 'bert-base-cased', 'bert-base-multilingual-cased' ...m = BertClassifier(output_dir='models/multilabel-bert-zh-model', num_classes=15,model_type='bert', model_name='bert-base-chinese', num_epochs=2, multi_label=True)# Train and Evaluation data needs to be in a Pandas Dataframe containing at least two columns, a 'text' and a 'labels' column. The `labels` column should contain multi-hot encoded lists.train_data = [["一個小時房間仍然沒暖和", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]],["耗電情況:這個沒有注意", [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],]data = load_jd_data('multilabel_jd_comments.csv')train_data.extend(data)print(train_data[:5])train_df = pd.DataFrame(train_data, columns=["text", "labels"])print(train_df.head())m.train(train_df)print(m)# Evaluate the modelacc_score = m.evaluate_model(train_df[:20])print(f'acc_score: {acc_score}')# load trained best model from model_dirm.load_model()predict_label, predict_proba = m.predict(['一個小時房間仍然沒暖和', '耗電情況:這個沒有注意'])print(f'predict_label: {predict_label}, predict_proba: {predict_proba}')

5.模型驗證

  1. THUCNews中文文本數據集(1.56GB):官方下載地址,抽樣了10萬條THUCNews中文文本10分類數據集(6MB),地址:examples/thucnews_train_10w.txt。
  2. TNEWS今日頭條中文新聞(短文本)分類 Short Text Classificaiton for News,該數據集(5.1MB)來自今日頭條的新聞版塊,共提取了15個類別的新聞,包括旅游,教育,金融,軍事等,地址:tnews_public.zip

在THUCNews中文文本10分類數據集(6MB)上評估,模型在測試集(test)評測效果如下:

模型acc說明
LR0.8803邏輯回歸Logistics Regression
TextCNN0.8809Kim 2014 經典的CNN文本分類
TextRNN_Att0.9022BiLSTM+Attention
FastText0.9177bow+bigram+trigram, 效果出奇的好
DPCNN0.9125深層金字塔CNN
Transformer0.8991效果較差
BERT-base0.9483bert + fc
ERNIE0.9461比bert略差

在中文新聞短文本分類數據集TNEWS上評估,模型在開發集(dev)評測效果如下:

模型acc說明
BERT-base0.5660本項目實現
BERT-base0.5609CLUE Benchmark Leaderboard結果 CLUEbenchmark
  • 以上結果均為分類的準確率(accuracy)結果
  • THUCNews數據集評測結果可以基于examples/thucnews_train_10w.txt數據用examples下的各模型demo復現
  • TNEWS數據集評測結果可以下載TNEWS數據集,運行examples/bert_classification_tnews_demo.py復現
  • 命令行調用

提供分類模型命令行調用腳本,文件樹:

pytextclassifier
├── bert_classifier.py
├── fasttext_classifier.py
├── classic_classifier.py
├── textcnn_classifier.py
└── textrnn_classifier.py

每個文件對應一個模型方法,各模型完全獨立,可以直接運行,也方便修改,支持通過argparse 修改--data_path等參數。

直接在終端調用fasttext模型訓練:

python -m pytextclassifier.fasttext_classifier -h

6.文本聚類算法

Text clustering, for example examples/cluster_demo.py

import syssys.path.append('..')
from pytextclassifier.textcluster import TextClusterif __name__ == '__main__':m = TextCluster(output_dir='models/cluster-toy', n_clusters=2)print(m)data = ['Student debt to cost Britain billions within decades','Chinese education for TV experiment','Abbott government spends $8 million on higher education','Middle East and Asia boost investment in top level sports','Summit Series look launches HBO Canada sports doc series: Mudhar']m.train(data)m.load_model()r = m.predict(['Abbott government spends $8 million on higher education media blitz','Middle East and Asia boost investment in top level sports'])print(r)########### load chinese train data from 1w data filefrom sklearn.feature_extraction.text import TfidfVectorizertcluster = TextCluster(output_dir='models/cluster', feature=TfidfVectorizer(ngram_range=(1, 2)), n_clusters=10)data = tcluster.load_file_data('thucnews_train_1w.txt', sep='\t', use_col=1)feature, labels = tcluster.train(data[:5000])tcluster.show_clusters(feature, labels, 'models/cluster/cluster_train_seg_samples.png')r = tcluster.predict(data[:30])print(r)

output:

TextCluster instance (MiniBatchKMeans(n_clusters=2, n_init=10), <pytextclassifier.utils.tokenizer.Tokenizer object at 0x7f80bd4682b0>, TfidfVectorizer(ngram_range=(1, 2)))
[1 1 1 1 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 1 1 9 1 1 8 1 1 9 1]

clustering plot image:

參考鏈接:https://github.com/shibing624/pytextclassifier

如果github進入不了也可進入 https://download.csdn.net/download/sinat_39620217/88205140 免費下載相關資料

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/37679.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/37679.shtml
英文地址,請注明出處:http://en.pswp.cn/news/37679.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

nodejs+vue+elementui+express智慧社區小區物業管理系統的設計與實現_2p760

開發語言 node.js 框架&#xff1a;Express 前端:Vue.js 數據庫&#xff1a;mysql 數據庫工具&#xff1a;Navicat 開發軟件&#xff1a;VScode 前端nodejsvueelementuiexpress vue的文件結構其實就是一個index.html 中間的內容&#xff0c;用的是vue&#xff0c;但最終都會轉…

OpenCV圖像處理——形態學操作

目錄 連通性形態學操作腐蝕和膨脹開閉運算禮帽和黑帽 連通性 形態學操作 形態學轉換是基于圖像形狀的一些簡單操作。它通常在二進制圖像上執行。腐蝕和膨脹時兩個基本的形態學運算符。然后它的變體形式如開運算&#xff0c;閉運算&#xff0c;禮帽黑帽等 腐蝕和膨脹 cv.erode…

費曼學習法

費曼學習法 費曼學習法&#xff08;Feynman Technique&#xff09;是一種學習和理解復雜概念的方法&#xff0c;以理查德費曼&#xff08;Richard Feynman&#xff09;這位著名的理論物理學家命名。該方法的核心思想是通過將學習內容簡化并用自己的話解釋給別人&#xff0c;來…

Node.js學習筆記-04

這第九章也是個大重點 九、玩轉進程 Node在選型時決定在V8引擎之上構建&#xff0c;也就意味著它的模型與瀏覽器類似。 本章關于進程的介紹和討論將會解決如下兩個問題&#xff1a; 單進程單線程并非完美&#xff0c;如今CPU基本均是多核的&#xff0c;真正的服務器&#xf…

背上小書包準備面試之TypeScript篇

目錄 typescript是啥&#xff1f;與javascript的區別&#xff1f; typescript數據類型&#xff1f; typescript中枚舉類型&#xff1f;應用場景&#xff1f; typescript中接口的理解&#xff1f;應用場景&#xff1f; typescript中泛型的理解&#xff1f;應用場景&#xf…

輕薄的ESL電子標簽有哪些特性?

在智慧物聯逐漸走進千萬家的當下&#xff0c;技術變革更加日新月異。ESL電子標簽作為科技物聯的重要組成部分&#xff0c;是推動千行百業數字化轉型的重要技術&#xff0c;促進物聯網產業的蓬勃發展。在智慧零售、智慧辦公、智慧倉儲等領域&#xff0c;ESL電子標簽在未來是不可…

win11右下角圖標(網絡,音量,電量)點擊無反應問題,兩分鐘解決!

win11系統用的好好的&#xff0c;突然有一天任務欄右下角的常用三件套&#xff08;網絡&#xff0c;音量&#xff0c;電量&#xff09;左鍵單擊沒反應&#xff0c;無法方便的調節音量和連接wifi&#xff0c;如下圖所示&#xff0c;但是右鍵好用&#xff0c;不過不方便。網上查了…

嵌入式 C 語言程序數據基本存儲結構

一、5大內存分區 內存分成5個區&#xff0c;它們分別是堆、棧、自由存儲區、全局/靜態存儲區和常量存儲區。 1、棧區(stack)&#xff1a;FIFO就是那些由編譯器在需要的時候分配&#xff0c;在不需要的時候自動清除的變量的存儲區。里面的變量通常是局部變量、函數參數等。 ?…

【Windows API】獲取卷標、卷名

1、卷->卷標 使用FindFirstVolume()和FindNextVolume()函數體系&#xff0c;枚舉系統所有卷&#xff08;Volume&#xff09;的例子&#xff0c;然后獲取卷標、卷類型。這個方式可以枚舉出沒有驅動器號&#xff08;卷標&#xff09;的卷。 int TestMode1() {HANDLE hVolume…

Failed to connect to bitbucket.org port 443

瀏覽器可以訪問bitbucket&#xff0c;但是在終端或者sourcetree上死活無法進行pull, push等操作。 Root Cause&#xff1a;“【翻】【墻】軟件”使用了http proxy&#xff0c;所以也得為git設置相同的http proxy。 所以&#xff0c;解決方法是&#xff1a; 1&#xff0c;查看“…

網絡系統架構演變

1.系統架構演變 隨著互聯網的發展&#xff0c;網站應用的規模不斷擴大。需求的激增&#xff0c;帶來的是技術上的壓力。系統架構也因此不斷的演進、升級、迭代。從單一應用&#xff0c;到垂直拆分&#xff0c;到分布式服務&#xff0c;到SOA&#xff0c;以及現在火熱的微服務架…

【Django】無法從“django.utils.encoding”導入名稱“force_text”

整晚處理 Django 的導入錯誤。 我將把它作為提醒&#xff0c;希望處于相同情況的人數會減少。 原因 某些軟件包版本不支持Django 4 請看下表并決定Django和Python的版本 方案 如果出現難以響應&#xff0c;或者更改環境麻煩&#xff0c;請嘗試以下操作 例如出現以下錯誤 …

云計算的發展前景怎么樣

云計算是當前科技領域中最受關注的領域之一,它的出現改變了傳統的計算模式,使得企業和個人能夠更加便捷地訪問和使用計算資源。隨著云計算技術的不斷發展,它的前景也變得更加光明。 以下是云計算的發展前景: 云計算的市場份額將繼續增長:根據市場研究機構的報告,云計算的市場份…

vfuhyuuy

Sublime Text is an awesome text editor. If you’ve never heard of it, you shouldcheck it out right now. I’ve made this tutorial because there’s no installer for the Linux versions of Sublime Text. While that’s not a real problem, I feel there is a clean…

通過版本號控制強制刷新瀏覽器或清空瀏覽器緩存

背景介紹 在我們做 web 項目時&#xff0c;經常會遇到一個問題就是&#xff0c;需要 通知業務人員&#xff08;系統用戶&#xff09;刷新瀏覽器或者清空瀏覽器 cookie 緩存的情況。 而對于用戶而言&#xff0c;很多人一方面不懂如何操作&#xff0c;另一方面由于執行力問題&am…

Android descendantFocusability 屬性

view 焦點問題處理 作用 通過該屬性可以指定viewGroup和其子View到底誰獲取焦點&#xff0c; 直接在viewGroup上使用就行。 屬性值 屬性值含義beforeDescendantsviewgroup會優先其子類控件而獲取到焦點afterDescendantsviewgroup只有當其子類控件不需要獲取焦點時才獲取焦點…

MFC創建和使用OCX控件

文章目錄 MFC建立OCX控件注冊OCX控件與反注冊使用Internet Explorer測試ocx控件OCX控件添加方法OCX控件添加事件Web使用OCX控件MFC使用OCX控件使用OCX控件調用ocx的功能函數對ocx的事件響應OCX控件調試工具tstcon32.exe加載ocx控件使用tstcon32.exe調試ocxMFC建立OCX控件 新建…

【ChatGPT 指令大全】怎么使用ChatGPT來輔助知識學習

目錄 概念解說 簡易教學 深度教學 教學與測驗 解釋一個主題的背后原理 總結 在當今信息時代&#xff0c;互聯網的快速發展為我們獲取知識提供了前所未有的便利。而其中&#xff0c;人工智能技術的應用也為我們的學習和交流帶來了新的可能性。作為一種基于自然語言處理的人…

ORA-01704: string literal too long

這是在做數據遷移的時候&#xff0c;將mysql庫中的數據整理成Oracle腳本&#xff0c;接著在客戶端運行sql腳本插入數據時碰到的問題。明顯就是文本太長了導致的報錯&#xff0c;但是實際上設置的字段是可以支持這么長的文本數據的。 解決方案 直接寫程序導出導入數據&#xff0…

Postgresql 基礎使用語法

1.數據類型 1.數字類型 類型 長度 說明 范圍 與其他db比較 Smallint 2字節 小范圍整數類型 32768到32767 integer 4字節 整數類型 2147483648到2147483647 bigint 8字節 大范圍整數類型 -9233203685477808到9223203685477807 decimal 可變 用戶指定 精度小…