<jupyter_start><jupyter_text><jupyter_code>import numpy as np
displacement = 307.0
horsepower = 130.0
weight = 3504.0
acceleration = 12.0
origin = 1
cylinder = 8

if cylinders == 3:
  cylinder = [1,0,0,0,0]
elif cylinders == 4:
  cylinder = [0,1,0,0,0]
elif cylinders == 5:
  cylinder = [0,0,1,0,0]
elif cylinders == 6:
  cylinder = [0,0,0,1,0]
else :
  cylinder = [0,0,0,0,1]

if origin == 1:
  org = [1,0,0]
elif origin == 2:
  org = [0,1,0]
else :
  org = [0,0,1]

X_customer = [[displacement, horsepower, weight, acceleration, cylinder, org]]
org = np.array([1,0,0])
displacement = 307.0
horsepower = 130.0
weight = 3504.0
acceleration = 12.0
cylinders = 8
origin = 1

# if cylinder = 8, origin = 1 --> onehot encording
import numpy as np

x_continues = np.array([displacement, horsepower, weight, acceleration])
# cylinder = np.array([0,0,0,0,1]) # 8
cylinder = onehotcylinder(cylinders)
org = np.array([1,0,0]) # 1
type(x_continues), type(cylinder), type(org)
# np.concatenate((a, b), axis=None)
result = np.concatenate((x_continues, cylinder, org), axis=None)
result.shape, result
# [307.0, 130.0, 3504.0, 12.0, 0,0,0,0,1]
# result.reshape(1,12)
result = result.reshape(-1, result.size)
result, result.shape, result.size
result.size, result<jupyter_output><empty_output><jupyter_text>function 이해<jupyter_code>23+78
39+59 
first = 38
second = 53
result = first - second
result
def sum():
  first = 32
  second =45
  result = first + second
  return result
sum()
def sum(f01, s02):
  first = f01
  second = s02
  result = first + second
  return result
sum(4,5)
def multi(n1, n2, n3):
  num1 = n1
  num2 = n2
  num3 = n3
  result = num1 * num2 * num3
  return result
multi(4,7,8)
def diffparam(*var_list, **var_dict):
  print(var_dict)
  result01 = len(var_list)
  return result01
diffparam(1,2,3, a=2, b=3)
diffparam(1,2,3,5,6, c=5, d=6, a=2, b=3)
def onehotcylinder(cylinders):
  if cylinders == 3:
    cylinder = [1,0,0,0,0]
  elif cylinders == 4:
    cylinder = [0,1,0,0,0]
  elif cylinders == 5:
    cylinder = [0,0,1,0,0]
  elif cylinders == 6:
    cylinder = [0,0,0,1,0]
  else :
    cylinder = [0,0,0,0,1]
  return cylinder
onehotcylinder(4), onehotcylinder(6)
cylinder<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16229656419529837, 'fraction_numerical': 0.09312839059674503, 'mean_word_length': 4.384428223844282, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '148617', 'license': 'Apache-2.0', 'n_tokens_mistral': 1049, 'n_tokens_neox': 956, 'n_words': 222, 'path': 'python_language.ipynb', 'repo_name': 'fonslucens/test_python', 'size': '2212'}