Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python
Python
  1. เขียนโปรแกรม Append Magic Numbers 1 ถึง 100 ลงใน Pandas Series

    ผลลัพธ์สำหรับการ Append Magic Numbers 1 ถึง 100 คือ magic number series: 0 1 1 10 2 19 3 28 4 37 5 46 6 55 7 64 8 73 9 82 10 91 11 100 เพื่อแก้ปัญหานี้ เราจะทำตามวิธีด้านล่าง − Solution 1 สร้าง List Comprehension Append ค่า 1 ถึง 100 เข้า List ls ls =

  2. เขียนโปรแกรม Python Pandas แปลงคอลัมน์ Celsius ใน DataFrame เป็น Fahrenheit

    ผลลัพธ์สำหรับการแปลง Celsius เป็น Fahrenheit คือ Id Celsius Fahrenheit 0 1 37.5 99.5 1 2 36.0 96.8 2 3 40.0 104.0 3 4 38.5 101.3 4 5 39.0 102.2 เพื่อแก้ปัญหานี้ เราจะทำตามวิธีด้านล่าง − Solution 1 กำหนด DataFrame พร้อมคอลัมน์ Id และ Cel

  3. เขียนโปรแกรม Python กรองคอลัมน์ City โดยลบ Prefix ที่ Unique ออกจาก DataFrame ที่กำหนด

    สมมติ คุณมี DataFrame ผลลัพธ์สำหรับการลบ Prefix ที่ Unique ของชื่อเมือง คือ Id City 2 3 Kolkata 3 4 Hyderabad 6 7 Haryana 8 9 Kakinada 9 10 Kochin เพื่อแก้ปัญหานี้ เราจะทำตามขั้นตอนด้านล่าง − Solution กำหนด DataFrame สร้าง List ว่างเพื่อ Append ตัวอักษรแรกของคอลัมน์ City

  4. เขียนโปรแกรม Python สร้าง Series ความยาวคู่ ของ PIN 4 หลักสุ่ม รับความยาวจากผู้ใช้ จนกว่าจะถูกต้อง

    ผลลัพธ์สำหรับการสร้าง PIN 4 หลักสุ่ม ความยาว Series เป็นเลขคู่ คือ enter the series size 4 Random four digit pin number series 0 0813 1 7218 2 6739 3 8390 เพื่อแก้ปัญหานี้ เราจะทำตามขั้นตอนด้านล่าง − Solution สร้าง List ว่าง และตั้ง Result เป็น True ตั้ง While Loop และรับ Size จากผ

  5. เขียนโปรแกรม Python แปลง DataFrame ที่กำหนดเป็นเอกสาร LaTeX

    สมมติ คุณมี DataFrame และผลลัพธ์สำหรับการแปลงเป็น LaTeX คือ \begin{tabular}{lrr} \toprule {} & Id & Age \\ \midrule 0 & 1 & 12 \\ 1 & 2 & 13 \\ 2 & 3 & 14 \\ 3 & 4 & 15 \\ 4 & 5 & 16 \\ \bottomrule \end{tabular} Solution เพื่อแก้ปัญหานี้ เราจะทำตามขั้นตอนด้านล่าง −

  6. เขียนโค้ด Python แปลง Series ที่กำหนดเป็น Dummy Variable และ Drop ค่า NaN หากมี

    สมมติ คุณมี Series และผลลัพธ์สำหรับการแปลงเป็น Dummy Variable คือ Female Male 0 0 1 1 1 0 2 0 1 3 1 0 4 0 1 5 0 0 6 1 0 7 1 0 เพื่อแก้ปัญหานี้ เราจะทำตามขั้นตอนด้านล่าง − Solution สร้าง List ที่มี Male และ Female แ

  7. เขียนโปรแกรม Python แยกคอลัมน์วันที่เป็น วัน เดือน ปี ใน DataFrame ที่กำหนด

    สมมติ คุณมี DataFrame และผลลัพธ์สำหรับคอลัมน์ Date, Month, Year คือ date day month year 0 17/05/2002 17 05 2002 1 16/02/1990 16 02 1990 2 25/09/1980 25 09 1980 3 11/05/2000 11 05 2000 4 17/09/1986 17 09 1986 เพื่อแก้ปัญหานี้ เราจะทำตามขั้นตอนด้านล่าง −

  8. เขียนโค้ด Python รวมสอง Series ที่กำหนดและแปลงเป็น DataFrame

    สมมติ คุณมีสอง Series และผลลัพธ์สำหรับการรวมสอง Series เป็น DataFrame คือ Id Age 0 1 12 1 2 13 2 3 12 3 4 14 4 5 15 เพื่อแก้ปัญหานี้ เราสามารถมี 3 วิธีที่แตกต่างกัน Solution 1 กำหนดสอง Series คือ series1 และ series2 Assign Series แรกเข้า DataFrame เก็บเป็น df df = pd.DataF

  9. เขียนโปรแกรม Python ตรวจสอบ CamelCase String แยก Camel Cases และเก็บใน Series ใหม่

    ผลลัพธ์สำหรับการแยก Camel Case Strings เป็น Series คือ enter the sring: pandasSeriesDataFrame Series is: 0 pandas 1 Series 2 Data 3 Frame dtype: object เพื่อแก้ปัญหานี้ เราจะทำตามขั้นตอนด้านล่าง − Solution กำหนดฟังก์ชันที่รับ Input String ตั้งค่าตัวแปร Result ด้วยเงื่อนไข Input ไม่

  10. วิธีใช้ TensorFlow Text แยกสตริง UTF-8 ใน Python

    สตริง UTF-8 สามารถแยกได้โดยใช้ TensorFlow Text สามารถทำได้ด้วย UnicodeScriptTokenizer UnicodeScriptTokenizer คือ Tokenizer ที่ถูกสร้างขึ้น หลังจากนั้น เมธอด tokenize ใน UnicodeScriptTokenizer จะถูกเรียกบนสตริง อ่านเพิ่มเติม: TensorFlow คืออะไร และ Keras ทำงานกับ TensorFlow อย่างไรในการสร้าง Neural

  11. วิธีใช้ TensorFlow Text แยกสตริงเป็นตัวอักษรด้วย unicode_split() ใน Python

    TensorFlow Text สามารถใช้แยกสตริงเป็นตัวอักษรด้วยเมธอด unicode_split โดยการ Encode สตริงที่แยกก่อน แล้ว Assign Function Call ให้ตัวแปร ตัวแปรนี้เก็บผลลัพธ์ของ Function Call อ่านเพิ่มเติม: TensorFlow คืออะไร และ Keras ทำงานกับ TensorFlow อย่างไรในการสร้าง Neural Networks? เราจะใช้ Keras Sequential A

  12. วิธีใช้ tf.text ตรวจสอบคุณสมบัติของสตริงใน Python

    เมธอด wordshape สามารถใช้ร่วมกับเงื่อนไขเฉพาะ เช่น HAS_TITLE_CASE, IS_NUMERIC_VALUE, หรือ HAS_SOME_PUNCT_OR_SYMBOL เพื่อดูว่าสตริงมีคุณสมบัติเฉพาะหรือไม่ อ่านเพิ่มเติม: TensorFlow คืออะไร และ Keras ทำงานกับ TensorFlow อย่างไรในการสร้าง Neural Networks? เราจะใช้ Keras Sequential API ซึ่งช่วยสร้าง Se

  13. การใช้ Whitespace Tokenizer ใน TensorFlow Text ด้วย Python

    แนวคิด ใช้ WhitespaceTokenizer สร้าง tokenizer เรียก tokenize บน string ใช้ Keras Sequential API, CNN, TensorFlow Text, Google Colab เหมือนเดิม Tokenization แบ่ง string เป็น tokens (คำ, ตัวเลข, ปunctuation) interfaces หลัก: Tokenizer และ TokenizerWithOffsets มีเมธอด tokenize และ tokenize_with_offse

  14. การกำหนด Feature Columns ใน TensorFlow ด้วย Python

    แนวคิด สร้าง feature columns สำหรับ Estimator โดยวนลูป keys ของ training dataset สร้าง numeric column ใช้ Keras Sequential API, CNN, TensorFlow Text, Google Colab, Estimator เหมือนเดิม ตัวอย่างโค้ด print(Building list of feature columns for estimator model) my_feature_columns = [] for key in train

  15. การสร้าง (Instantiate) Estimator ด้วย TensorFlow และ Python

    แนวคิด สร้าง Estimator ด้วย DNNClassifier ใน tf.estimator ใช้ Keras Sequential API, CNN, TensorFlow Text, Google Colab, Estimator, Iris dataset เหมือนเดิม ตัวอย่างโค้ด print(Build a DNN that has 2 hidden layers with 30 and 10 hidden nodes each) classifier = tf.estimator.DNNClassifier( feature_

  16. การเทรนโมเดล (Compile/Train) ด้วย TensorFlow Estimator

    แนวคิด ใช้ train method เทรนโมเดล ใช้ Keras Sequential API, CNN, TensorFlow Text, Google Colab, Estimator, Iris dataset เหมือนเดิม ตัวอย่างโค้ด print(The model is being trained) classifier.train(input_fn=lambda: input_fn(train, train_y, training=True), steps=5000) Credit: TensorFlow Tutorials ผลล

  17. การประเมินโมเดลด้วย TensorFlow Estimator และ Python

    แนวคิด ใช้ evaluate method ใน classifier module ประเมินโมเดล ใช้ Keras Sequential API, CNN, TensorFlow Text, Google Colab, Estimator, Iris dataset เหมือนเดิม ตัวอย่างโค้ด eval_result = classifier.evaluate(input_fn=lambda: input_fn(test, test_y, training=False)) print(\nTest dataset accuracy is: {a

  18. การทำนายจากโมเดลที่เทรนแล้วด้วย TensorFlow Estimator

    แนวคิด ใช้ predict method ใน classifier ทำนายข้อมูลใหม่ ใช้ Keras Sequential API, CNN, TensorFlow Text, Google Colab, Estimator เหมือนเดิม โมเดลเทรนด้วย Iris dataset มี 4 features 1 label: sepal length, sepal width, petal length, petal width ตัวอย่างโค้ด print(Generating predictions from model) ex

  19. การทำนายผลลัพธ์ด้วย TensorFlow Estimator และ Python

    แนวคิด เรียกเมธอด predict บนข้อมูลใหม่ แสดง predictions และค่าจริง ใช้ Keras Sequential API, CNN, TensorFlow Text สำหรับ preprocessing sequence, Google Colab Estimator เป็น high-level model representation รองรับ scaling และ async training ตัวอย่างโค้ด for pred_dict, expec in zip(predictions, expec

  20. การตรวจสอบ Titanic Dataset ด้วย TensorFlow Estimators

    แนวคิด ตรวจสอบ dataset ด้วย Estimators โดย iterate features แปลงเป็น list แสดงผล ใช้ Keras Sequential API, CNN, Google Colab เหมือนเดิม Estimator เป็น high-level representation ของโมเดลสมบูรณ์ใน TensorFlow ออกแบบให้ scale ง่าย รองรับ asynchronous training จะเทรน Logistic Regression ด้วย tf.estimato

Total 9001 -คอมพิวเตอร์  FirstPage PreviousPage NextPage LastPage CurrentPage:234/451  20-คอมพิวเตอร์/Page Goto:1 228 229 230 231 232 233 234 235 236 237 238 239 240